php5

Custom model fields for a CMS

I've very fond of mapping my models using an ORM like Doctrine. For an upcoming project, I need to allow the user to add custom fields to my models. I was wondering the best way to go about doing this? In the past I have done this by creating a database table 'custom fields' which looks like this: field_id->pk field_model->ida field_t...

PHP: Array of objects is empty when I come to retrieve one from the array

Good morning, I am trying to load rows from a database and then create objects from them and add these objects to a private array. Here are my classes: <?php include("databaseconnect.php"); class stationItem { private $code = ''; private $description = ''; public function setCode($code ){ $this->code = $code; ...

php zf project: db classes in models directory do not get auto-included

Hiya. I'm trying to create a Zend Framework project using PHP 5.3.2 and Zend Framework 1.10.3. i created the source files of the project using the zend framework tool and the db related classes i created with zend-db-model-generator. example: in models directory i have the following: FbUser.php - class Default_Model_FbUser FbUserMapp...

How do I write a custom validator for a zend form element with customized error messages?

I have a question field with a list of allowed characters : A-Z,0-9,colon (:), question mark (?), comma(,), hyphen(-), apostrophe ('). I have the regex which works fine, in the fashion : $question->addValidator('regex', true, array(<regular expresstion>)) The default error message is something like ''' does not match against pattern ...

PHP Doc software on OSX?

I use my OSX for dev. PHP and now i need to try PHPDoc but how? sombardy know a software? or how i can doe it? i try to look here http://manual.phpdoc.org/HTMLSmartyConverter/HandS/ric_INSTALL.html but i hobe i can found a GUI software the out. :) tanks for all help. ...

Recursing data into a 2 dimensional array in PHP 5

I'm getting bamboozled by "for each" loops and two dimensional arrays, and I'm a php newb so please bear with me (and ignore any variables with the word "image" - it's all about the mp3s, I just didn't change it from the xml tutorial) I found a php function on the net that list files in a directory, the output of which is: Array ( [0...

PHP: need json_encode() 5.3 functionality in 5.2

Long story short, client's hosting is using php 5.2.5 and i desperately need to use the JSON_FORCE_OBJECT option with json_encode() that came with 5.3. Does anyone know some equivalent for that purpose? Point it out please. ...

Single HTML Table from multiple MySQL tables

Hi! I've been struggling for a while with this one; I'll try to explain it here as simply as possible. Consider this MySQL table: +----------+-----------+---------+--------+ |status_id |session_id |pilot_id |present | +----------+-----------+---------+--------+ |1 |61 |901 |1 | |2 |63 |901 ...

Cake php menu generation

hai everyone........ I am trying to generate dynamic menu according to the user permission given with ACL component in cake php.. ie., if a user logins, i need to check which all actions are permitted for that specific user and according that list of actions i need to generate menu can any one help me to get all the permitted actions ...

Updating joomla site in production from developpement server

Hello everybody, I've two sites buit on joomla. Theye are respectivly hosted in two defferent servers. The first one is the developpement machine and the other is where is the production. I frequently modify articles, some files... in the developpement machine. I would like to know wether it is possible to update automatically the produ...

What does RETURN TRUE do in a php function?

I was just looking at this code and i don't understand what RETURN TRUE does or what the point of it is? Can someone please explain? class Elephpant { public $colour; public function dance() { echo "elephpant dances!\n"; return true; } } Thankyou in advance ;-) ...

Can a PHP object respond to an undefined method?

Rails relies on some of the neat aspects of Ruby. One of those is the ability to respond to an undefined method. Consider a relationship between Dog and Owner. Owner has_many :dogs and Dog belongs_to :owner. If you go into script/console, get a dog object with fido = Dog.find(1), and look at that object, you won't see a method or attri...

Magic Method __set() on a Instantiated Object

Ok i have a problem, sorry if i cant explaint it clear but the code speaks for its self. i have a class which generates objects from a given class name; Say we say the class is Modules: public function name($name) { $this->includeModule($name); try { $module = new ReflectionClass($name); $instance = $module->i...

YQL and FLickr query not understood in the console

Hello, So I am trying to use YQL to access the flickr api but I have been having some issues. From reading the YQL info, it seemed like I could use any flickr query in YQL but for some reason I cannot use flickr.people.getPublicPhotos call to access all pictures from a certain person. When I try any such query it isn't recognized. Is th...

PHP date causing XML error

Hi guys! Using PHP Version 5.2.13, I'm trying to use the date() function to get/format date, such function is causing me to get all page in blank and firebug is showing the following error (XML tab): XML Parsing Error: no element found Location: moz-nullprincipal:{e80b3b2e-b8f1-4a2d-b906-03d42ca6a190} Line Number 1, Column 1: ^ <td ...

Installing PHP extensions in Debian

I'm trying to install the PECL extension pecl_http so that I can use PHP's http_negotiate_language() function. I'm running PHP5 on Apache2 and Debian Lenny. I installed the php_http package from the debian repo, however, I still can't use that function in my php scripts! The package also doesn't show up under phpinfo(). I tried installi...

Unexpected T_ELSE error in PHP

I am working on an example from a php book and am getting an error on line 8 with this code <?php $agent = getenv("HTTP_USER_AGENT"); if (preg_match("/MSIE/i", "$agent")); { $result = "You are using Microsoft Internet Explorer"; } else if (preg_match("/Mozilla/i", "$agent")); { $result = "You are using Mozilla firefox"; } else...

How to structure a Kohana MVC application with dynamically added fields and provide validation and feedback

I've got a bit of a problem. I have a Kohana application that has dynamically added fields. The fields that are added are called DISA numbers. In the model I look these up and the result is returned as an array. I encode the array into a JSON string and use JQuery to populate them The View knows the length of the array and so creates ...

HTML and PHP simple contact form.

I tried to make a simple contact form via HTML and PHP but the form doesnt seem to submit. it stays on the HTML page and doesnt post to the php form. would love someone to look over the code, thanks in advanced. simple_form.html cdoe <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xh...

How to create array items by specify a key that includes hierachy ?

Given original codes as: foreach($option as $name=>$value) $array[$name] = $value; and $name as button[0][text], button[0][value], button[1][text], spider[0][name], ... The result array would be array('button[0][text]' => 'its text', 'button[0][value]' => 'its value', 'button[1][text]' => 'its text', 'spider[0][nam...