Message: [Syntax Error] Expected PlainValue, got ”’ at position x in property {model}
Was getting the above error in my Doctrine project, turned out I had used a single quote in the ORM Annotations: /** * @ORM\Column(type=’integer’, name=’row_number’) * @var int */ protected $rowNumber; Your ORM Annotations must be double quotes ” to allow the read ahead to read ahead…
Accessing controller data from a partial viewscript
When using an inline partial viewscript in my form, I sometimes need access to data. I can accomplish this by using a setter and getter with a public function in my form. We’ll use the action “guinness” as the controller action in this example. application\modules\project\forms\guinness\base.php protected $_id; public function setId($id) { $this->_id = $id; return [...]
Setting up Class Table Inheritance with Doctrine 2.0
Have had some serious problems getting this working, but after a 4 hour head bashing session, we’ve cracked it. CREATE TABLE inventory( inventory_id INT AUTO_INCREMENT, discriminator_column VARCHAR(20), category VARCHAR(50) NOT NULL, part_number VARCHAR(50) NOT NULL, PRIMARY KEY (inventory_id), KEY category_part_number (category, part_number), KEY discriminator_column (discriminator_column) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; CREATE TABLE inventory_room( inventory_id INT NOT [...]
SVN Externals – how to add them
When creating a Zend Framework site, its always best to keep the Zend library as an external source. This way you can keep the branch up-to-date with the release of Zend with a simple text file. To access the externals file, navigate to the root of your site: > cd /var/www/mysite And add the external [...]
PHP App Testing
Think: “What am I testing?” 1) Set-up Instantiate your class Look for dependencies, are there any that need mocking? 2) Exercise We test our real objects that need testing, or mock objects that don’t but are required by SUT (System Under Test) 3) Verify Real object results Expectations of mocked objects 4) Tear down Destroy [...]
How to pass data from Controller to Zend Form
To pass data from your controller, to a Zend_Form, you can utilise the config parameters: $this->view->form = new Contact_Edit_Form(array(‘contactName’ => ‘Chris’)); This will pass a very simple array to the form, and from within the form, $data = $this->getAttrib(‘contactName’); $data will then contain Chris
Zend Console – get values passed
When using a CLI script with options, I like to use the Zend_Console. If my options are as follows: $console = new Zend_Console_Getopt( array( ‘i-s’ => ‘test option 1′, ‘e’ => ‘test option 2′) ); For instance, > php myScript.php -i OPTION To get the “OPTION” string for the -i parameter $arg = $console->getOption(‘i’); $arg [...]
Zend_Db – Performing a LIKE search
When performing a simple SQL search using Zend_Db_Select, $select->where(‘name = ?’, ‘chris’); But what if you want to do a LIKE search? $select->where(‘name LIKE ?’, ‘chris%’); Simples.
Setting up postfix on Ubuntu for mailing from PHP
To allow your Ubuntu server to send emails from PHP, then you need to install postfix. Postfix is a mailer for *nix platforms. So, to install it: sudo apt-get install postfix When this is installing, you’ll need to enter some options, like what sort of server you’re connecting to. I use my companies details in [...]
Zend_Date – difference between 2 dates
I keep having trouble with this simple calculation! So, here is a little example to get the amount of days between now and the next occurance of July 1st. //set up the 2 date objects $now = new Zend_Date(); $next = new Zend_Date(); //we want July 1st $next->setDay(1)->setMonth(7); //if we are currently after july this [...]
keep looking »