Chris Tate-Davies

An archive of helpful tit bits of information for development, and probably some stuff that is incomplete, wrong or boring…

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…  

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 [...]

Accessing the Zend_Application from a page

If, like me, you need to access some Zend_Application resources (such as multidb resources) – then you need a reference to the Zend_Application and the bootstrap. I use this: if (null == $this->_application) { $this->_application = Zend_Controller_Front::getInstance() ->getParam(‘bootstrap’); }

keep looking »
  • Chris Tate-Davies

    Hello there. This is my little "repository" on the world wide web. Its for nothing more than documenting things that I might need again in the future. You could describe it as an extension to my memory.

    Also an online collaboration of my thoughts through the day. I'll try to keep the real random stuff out and keep the blog on course.

    Thanks for stopping by... Hope you find what you're looking for...

  • Tags