php

What is the Algorithm for an ORM?

I've been digging around for an ORM to use in a php/mysql application. However none quite grab my attention past "hello world" tests. So, I decided to do some research and try to code my own custom ORM. However I haven't been able to find resources that explain at code level how to handle db relationships. The concept of how an ORM works...

In PHP how do i write: IS NOT SMALLER THAN

For example: a is not smaller than b How do i write this ? ...

Writing model methods in Doctrine

Hello! I'd like to encapsulate functionality specific to certain models by including methods in the model class definitions. So, for example: abstract class BaseUser extends DoctrineRecord { public function setTableDefinition(){ //etc. } public function setUp(){ //etc. } public functio...

Drupal - using boostrap to check logged in user outside of Drupal not working

I'm pulling my hair out trying to figure this one out. I can't get the Bootstrap to work properly when outside of the Drupal dir. It works fine if I run this code in the Drupal dir, but up one level doesn't work. My Drupal path is /public_html/drupal/. The script I'm running is in /public_html. $user is not returning the logged in use...

PHP HttpRequest::setHeaders() converting my header names to camel case

I need to send the following header with my httpRequest: 'X-ABC-Reco-Token'=>'a0d15977'; I have the following code: $array = array("X-ABC-Reco-Token"=>$token); $this->request->setHeaders($array); echo var_dump($this->request->getHeaders()); however, this is the output I get: "X-Abc-Reco-Token"=...

UTF8 characters not printed as such in Drupals HTML.

I am trying to debug a nasty utf-8 problem, and do not know where to start. A page contains the word 'categorieën', wich should be categorieën. Clearly something is wrong with the UTF-8. This happens with all these multibite characters. I have scanned the gazillion topics here on UTF8, but they mostly cover the basics, not this situat...

Trouble retrieving products under a complex category structure in PHP

Hello, I hope you guys can help me with this one. So, I have a products table and a categories table. The structure for the categories table is listed bellow. There will be about 20 categories with three or four levels deep. In order to get the category tree a wrote a recursive function and it is working fine. My new task is to displa...

Php function limiting the amount of passed in characters.

I have a certain amount of characters that I can fit in the spot I want to display the category. So I was wondering if there was a way I could limit the ammount of characters that this function can output. I want to limit this functions output: <?php the_category(', ') ?> outputs: WordPress, Computers, Blogging Something like this: ...

Calling a PHP function defined in another namespace without the prefix

When you define a function in a namespace, namespace foo { function bar() { echo "foo!\n"; } class MyClass { } } you must specify the namespace when calling it from another (or global) namespace: bar(); // call to undefined function \bar() foo\bar(); // ok With classes you can employ the "use" statement to eff...

The best way to create log-in realm in PHP

I can do login realm in PHP and the way that I do it is by setting a session variable and check whether that session variable is set or not. On every restricted page, I check whether a certain session variable is set (or is equal to a certain value). If not, then i will send the user back to the login page. Is this the best way to do it?...

PHP is it possible to convert array to vars and pass them somewhere

In short, what I want is a kind of export() function (but not export()), it creates new variables in symbol table and returns the number of created vars. I'm trying to figure out if it is possible to declare a function function foo($bar, $baz) { var_dump(func_get_args()); } And after that pass an array so that each value of array...

session variable php login realm

I am wondering whether its possible to change/set/delete my session variable AS A USER. I am re-thinking the way that I do login realm in PHP. The way that I do it now is that I check whether a certain session variable is set or not. However, this would break if someone can just change his/her session variable. ...

Can php convert strings with all charset encodes to utf8

Hi, Can php convert strings with all charset encodes to utf8? Solutions that don't works: utf8_encode($string) - but its only Encodes an ISO-8859-1 string to UTF-8? iconv($incharset, $outcharset,$text) - but how can be find string current encodding? (only can be if string part of html dom document, not just string) thanks ...

PHP REGEX: Problem with Smiley `:)` and `:))`

What I want Hi! I want to replace :) to smile.png and :)) to laugh.png. The problem The script finds :) inside :)) so laugh.png is not shown, only smile.png+) This is what I have tried so far for :)): preg_replace("/:)+(?!))/i",$image, $string)) Some other regexes what I tried: "/\:\)+(?=\))/i" "/\:+(?=\)\))/i" But nothing...

Using Codeigniter Escape function

I have recently added a comments section to a blog. Codeigniter says to always escape data before putting it into the Db.(I do have xss clean on fulltime). Some people say all active record operations are escaped. Am I wasting my time using escape on the function below? Using the function below I escape the data, but it all comes out ...

handling html radio boxes with php

Hi, I have a simple HTML form which consists of radio buttons where user has to select 1 out of three. Now the Objective is to save the responses of the user, so we admin can view them later. I am more interested in their actual response rather than values field. here is the sample code <table border="0"> <tr><td><input type="hidden" ...

xpath php sort attribute based on greater than date

Need to xpath xml data based on greater than date attribute. The dashes in the date below prevent the greater than symbol from working. Is there a way to remove the dashes in the xml on the fly? XML <revisions> <revision date="2010-07-12">blah</revision> <revision date="2010-06-12">blah</revision> </revisions> PHP $rdate = 2010-...

Return the fields that do not pass validation in PHP to jQuery

I'm using jQuery with PHP for form validation. I want to return the fields that do not validate so i can highlight them using javascript this is my attempt using PHP(validate.php): <?php ... $a_invalidInput = array(); $from = $_POST['from']; $to = $_POST['to']; $email_to = $_POST['email_to']; if( empty($from) ){ $a_invalidInput[] ...

php: difference between to isset methods?

hey guys, not sure how i should name the title of the post. i'm having a submitbutton on my page that's creating a folder for me. as soon as i press it. the site AUTOMATICALLY refreshes. There's no script set in my document that says the page should refresh. it just happens when i submit anything, right? if (isset($_POST['createDir'])...

strategy to split up php output into smaller outputs (ajax, php) (nested ajax calls, ajax within ajax?)

Hi, I don't know the correct terminology to search for the solution. Please suggest a strategy to break up the php output into small chunks and pass them stepwise to ajax's responseText. The project is an ajax webpage that takes a text string (lastname) and passes it to a php program. The php code takes the last name and randomly fet...