<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Chris Tate-Davies &#187; PHP</title>
	<atom:link href="http://www.christatedavies.co.uk/category/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.christatedavies.co.uk</link>
	<description>An archive of helpful tit bits of information for development, and probably some stuff that is incomplete, wrong or boring...</description>
	<lastBuildDate>Tue, 31 Jan 2012 11:18:39 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Message: [Syntax Error] Expected PlainValue, got &#8221;&#8217; at position x in property {model}</title>
		<link>http://www.christatedavies.co.uk/2011/12/14/message-syntax-error-expected-plainvalue-got-at-position-x-in-property-model/</link>
		<comments>http://www.christatedavies.co.uk/2011/12/14/message-syntax-error-expected-plainvalue-got-at-position-x-in-property-model/#comments</comments>
		<pubDate>Wed, 14 Dec 2011 10:36:03 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Doctrine]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[annotation]]></category>
		<category><![CDATA[doctrine]]></category>
		<category><![CDATA[ORM]]></category>
		<category><![CDATA[PlainValue]]></category>
		<category><![CDATA[quotes]]></category>

		<guid isPermaLink="false">http://www.christatedavies.co.uk/?p=316</guid>
		<description><![CDATA[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 &#8221; to allow the read ahead to read ahead&#8230; &#160;<div class="addthis_toolbox addthis_default_style addthis_" addthis:url='http://www.christatedavies.co.uk/2011/12/14/message-syntax-error-expected-plainvalue-got-at-position-x-in-property-model/' addthis:title='Message: [Syntax Error] Expected PlainValue, got &#8221;&#8217; at position x in property {model} ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></description>
			<content:encoded><![CDATA[<p>Was getting the above error in my Doctrine project, turned out I had used a single quote in the ORM Annotations:</p>
<pre>    /**
     * @ORM\Column(type='integer', name='row_number')
     * @var int
     */
    protected $rowNumber;</pre>
<p>Your ORM Annotations <strong>must</strong> be double quotes &#8221; to allow the read ahead to read ahead&#8230;</p>
<p>&nbsp;</p>
<div class="addthis_toolbox addthis_default_style addthis_" addthis:url='http://www.christatedavies.co.uk/2011/12/14/message-syntax-error-expected-plainvalue-got-at-position-x-in-property-model/' addthis:title='Message: [Syntax Error] Expected PlainValue, got &#8221;&#8217; at position x in property {model} ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></content:encoded>
			<wfw:commentRss>http://www.christatedavies.co.uk/2011/12/14/message-syntax-error-expected-plainvalue-got-at-position-x-in-property-model/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Accessing controller data from a partial viewscript</title>
		<link>http://www.christatedavies.co.uk/2011/11/17/accessing-controller-data-from-a-partial-viewscript/</link>
		<comments>http://www.christatedavies.co.uk/2011/11/17/accessing-controller-data-from-a-partial-viewscript/#comments</comments>
		<pubDate>Thu, 17 Nov 2011 15:43:36 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Zend Framework]]></category>
		<category><![CDATA[forms]]></category>
		<category><![CDATA[partial]]></category>
		<category><![CDATA[render]]></category>
		<category><![CDATA[Viewscript]]></category>
		<category><![CDATA[Zend]]></category>
		<category><![CDATA[zend framework]]></category>
		<category><![CDATA[Zend_Form]]></category>

		<guid isPermaLink="false">http://www.christatedavies.co.uk/?p=273</guid>
		<description><![CDATA[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&#8217;ll use the action &#8220;guinness&#8221; as the controller action in this example. application\modules\project\forms\guinness\base.php protected $_id; public function setId($id) { $this-&#62;_id = $id; return [...]<div class="addthis_toolbox addthis_default_style addthis_" addthis:url='http://www.christatedavies.co.uk/2011/11/17/accessing-controller-data-from-a-partial-viewscript/' addthis:title='Accessing controller data from a partial viewscript ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></description>
			<content:encoded><![CDATA[<p>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&#8217;ll use the action &#8220;guinness&#8221; as the controller action in this example.</p>
<p><strong>application\modules\project\forms\guinness\base.php</strong></p>
<pre>protected $_id;

public function setId($id)
{
    $this-&gt;_id = $id;
    return $this;
}

public function getId()
{
    return $this-&gt;_id;
}

public function getPintCount()
{
    $model = new PubModel();
    return $model-&gt;countPints(this-&gt;getId());
}</pre>
<p><strong>application\modules\project\views\scripts\guinness\page.phtml</strong></p>
<pre>&lt;?=$this-&gt;render('_partial.phtml');?&gt;</pre>
<p><strong>application\modules\project\controllers\GuinnessController.php</strong></p>
<pre>&lt;?php
$form = new SomeForm();
$form-&gt;setId(123);
?&gt;</pre>
<p><strong>application\modules\projects\views\scripts\guinness\_partial.phtml</strong></p>
<pre>&lt;?=$this-&gt;element-&gt;getPintCount();?&gt;</pre>
<p>&nbsp;</p>
<p>This way I can get the content view my connected partials which in essence are a copy of the viewscript.</p>
<p>Seems a long way round, but it keeps everything nicely separated.</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<div class="addthis_toolbox addthis_default_style addthis_" addthis:url='http://www.christatedavies.co.uk/2011/11/17/accessing-controller-data-from-a-partial-viewscript/' addthis:title='Accessing controller data from a partial viewscript ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></content:encoded>
			<wfw:commentRss>http://www.christatedavies.co.uk/2011/11/17/accessing-controller-data-from-a-partial-viewscript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Setting up Class Table Inheritance with Doctrine 2.0</title>
		<link>http://www.christatedavies.co.uk/2011/09/13/setting-up-class-table-inheritance-with-doctrine-2-0/</link>
		<comments>http://www.christatedavies.co.uk/2011/09/13/setting-up-class-table-inheritance-with-doctrine-2-0/#comments</comments>
		<pubDate>Tue, 13 Sep 2011 10:51:58 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Doctrine]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Zend Framework]]></category>
		<category><![CDATA[abstract]]></category>
		<category><![CDATA[classes]]></category>
		<category><![CDATA[doctrine]]></category>
		<category><![CDATA[inheritance]]></category>
		<category><![CDATA[Object-Relational Mapping]]></category>
		<category><![CDATA[ORM]]></category>
		<category><![CDATA[zend framework]]></category>

		<guid isPermaLink="false">http://www.christatedavies.co.uk/?p=234</guid>
		<description><![CDATA[Have had some serious problems getting this working, but after a 4 hour head bashing session, we&#8217;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 [...]<div class="addthis_toolbox addthis_default_style addthis_" addthis:url='http://www.christatedavies.co.uk/2011/09/13/setting-up-class-table-inheritance-with-doctrine-2-0/' addthis:title='Setting up Class Table Inheritance with Doctrine 2.0 ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></description>
			<content:encoded><![CDATA[<p>Have had some serious problems getting this working, but after a 4 hour head bashing session, we&#8217;ve cracked it.</p>
<pre>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;</pre>
<pre>CREATE TABLE inventory_room(
    inventory_id INT NOT NULL,
    rack_limit INT(6),
    room_type VARCHAR(25),
    KEY inventory_id (inventory_id),
    CONSTRAINT inventory_room_key FOREIGN KEY (inventory_id) REFERENCES inventory (inventory_id)
        ON DELETE CASCADE
        ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;</pre>
<p>You have to have a discriminator field so that Doctrine can connect the tables nicely when its joining them.</p>
<pre>&lt;?php
namespace Net\Model\Inventory;
use Doctrine\ORM\Mapping as ORM;

/**
 * Inventory entity
 *
 * @ORM\Entity(repositoryClass="Net\Repository\Inventory")
 * @ORM\Table(name="inventory")
 * @ORM\InheritanceType("JOINED")
 * @ORM\DiscriminatorColumn(name="discriminator_column", type="string")
 * @ORM\DiscriminatorMap({"inventory" = "AbstractItem", "inventory_room" = "Room"})
 *
 * @category Net
 * @package  Model
 */
abstract class AbstractItem
{
    /**
     * @ORM\Id @ORM\Column(name="inventory_id") @ORM\GeneratedValue
     * @var int
     */
    protected $inventory_id;

    /**
     * @ORM\Column(type="string")
     * @var string
     */
    protected $category;    

    /**
     * @ORM\Column(type="string")
     * @var string
     */
    protected $part_number;
 }</pre>
<p>As you can see in the above class, we have a ORM\GeneratedValue field. This tells Doctrine that this field is an increment field. As this is a one-to-one relationship we do not need one in the inventory_room table as it will be joined on the inventory_id field.</p>
<p>In the next class, this is the child class that extends the abstract. So Doctrine will read the annotations at the top and see that its a joined table using the id field (inventory_id)</p>
<pre>&lt;?php
namespace Net\Model\Inventory;
use Doctrine\ORM\Mapping as ORM;

/**
 * Inventory Room entity
 * @ORM\Entity
 * @ORM\Table(name="inventory_room")
 *
 * @category Net
 * @package  Model
 */
class Room extends AbstractItem
{
    /**
     * @ORM\Column(type="string")
     * @var string
     */
    protected $room_type;

    /**
     * @ORM\Column(type="string")
     * @var string
     */
    protected $rack_limit;
}</pre>
<div class="addthis_toolbox addthis_default_style addthis_" addthis:url='http://www.christatedavies.co.uk/2011/09/13/setting-up-class-table-inheritance-with-doctrine-2-0/' addthis:title='Setting up Class Table Inheritance with Doctrine 2.0 ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></content:encoded>
			<wfw:commentRss>http://www.christatedavies.co.uk/2011/09/13/setting-up-class-table-inheritance-with-doctrine-2-0/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>SVN Externals &#8211; how to add them</title>
		<link>http://www.christatedavies.co.uk/2011/09/08/svn-externals-how-to-add-them/</link>
		<comments>http://www.christatedavies.co.uk/2011/09/08/svn-externals-how-to-add-them/#comments</comments>
		<pubDate>Thu, 08 Sep 2011 10:16:08 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[IT]]></category>
		<category><![CDATA[JQuery]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Zend Framework]]></category>
		<category><![CDATA[command line]]></category>
		<category><![CDATA[subversion]]></category>
		<category><![CDATA[svn]]></category>
		<category><![CDATA[terminal]]></category>
		<category><![CDATA[Zend]]></category>
		<category><![CDATA[zend framework]]></category>

		<guid isPermaLink="false">http://www.christatedavies.co.uk/?p=231</guid>
		<description><![CDATA[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: &#62; cd /var/www/mysite And add the external [...]<div class="addthis_toolbox addthis_default_style addthis_" addthis:url='http://www.christatedavies.co.uk/2011/09/08/svn-externals-how-to-add-them/' addthis:title='SVN Externals &#8211; how to add them ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></description>
			<content:encoded><![CDATA[<p>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.</p>
<p>To access the externals file, navigate to the root of your site:</p>
<pre>&gt; cd /var/www/mysite</pre>
<p>And add the external to the svn:externals file. I am using the latest version of Zend Framework for this, but you can use any SVN source you like. Note, it <strong>has</strong> to be available as an SVN repository.</p>
<pre>&gt; svn propedit svn:externals .</pre>
<p>This will open a text editor.</p>
<p>To enter an external, just enter the local folder to download to, and the source SVN.</p>
<pre>destination source</pre>
<p>So, if I want my Zend Framework files to be saved in /var/www/mysite/library/Zend :</p>
<pre>library/Zend http://framework.zend.com/svn/framework/standard/tags/release-1.11.9/library/Zend/</pre>
<p>The first part is the local, second part is the URL of the repository.</p>
<p>Save and close.</p>
<p>Next time you do an update, svn will go and fetch the external files and save them for you.</p>
<p>Other externals are available, such as JQuery, various wikis and other JS sources.</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<div class="addthis_toolbox addthis_default_style addthis_" addthis:url='http://www.christatedavies.co.uk/2011/09/08/svn-externals-how-to-add-them/' addthis:title='SVN Externals &#8211; how to add them ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></content:encoded>
			<wfw:commentRss>http://www.christatedavies.co.uk/2011/09/08/svn-externals-how-to-add-them/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP App Testing</title>
		<link>http://www.christatedavies.co.uk/2011/06/09/php-app-testing/</link>
		<comments>http://www.christatedavies.co.uk/2011/06/09/php-app-testing/#comments</comments>
		<pubDate>Thu, 09 Jun 2011 10:07:31 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[PHPUnit]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://www.christatedavies.co.uk/?p=180</guid>
		<description><![CDATA[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 [...]<div class="addthis_toolbox addthis_default_style addthis_" addthis:url='http://www.christatedavies.co.uk/2011/06/09/php-app-testing/' addthis:title='PHP App Testing ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></description>
			<content:encoded><![CDATA[<h2>Think: “What am I testing?”</h2>
<h3>
1) Set-up</h3>
<p>Instantiate your class</p>
<p>Look for dependencies, are there any that need mocking?</p>
<h3>2) Exercise</h3>
<p>We test our real objects that need testing,</p>
<p>or mock objects that don’t but are required by SUT (System Under Test)</p>
<h3>3) Verify</h3>
<p>Real object results</p>
<p>Expectations of mocked objects</p>
<h3>4) Tear down</h3>
<p>Destroy objects if needed?</p>
<p>&nbsp;</p>
<p>The four-phased testing technique explained here: <a href="http://xunitpatterns.com/Four%20Phase%20Test.html">http://xunitpatterns.com/Four%20Phase%20Test.html</a></p>
<p>&nbsp;</p>
<div class="addthis_toolbox addthis_default_style addthis_" addthis:url='http://www.christatedavies.co.uk/2011/06/09/php-app-testing/' addthis:title='PHP App Testing ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></content:encoded>
			<wfw:commentRss>http://www.christatedavies.co.uk/2011/06/09/php-app-testing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to pass data from Controller to Zend Form</title>
		<link>http://www.christatedavies.co.uk/2011/05/20/how-to-pass-data-from-controller-to-zend-form/</link>
		<comments>http://www.christatedavies.co.uk/2011/05/20/how-to-pass-data-from-controller-to-zend-form/#comments</comments>
		<pubDate>Fri, 20 May 2011 14:56:53 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Zend Framework]]></category>
		<category><![CDATA[controller]]></category>
		<category><![CDATA[forms]]></category>
		<category><![CDATA[Zend]]></category>
		<category><![CDATA[zend framework]]></category>
		<category><![CDATA[Zend_Form]]></category>

		<guid isPermaLink="false">http://www.christatedavies.co.uk/?p=171</guid>
		<description><![CDATA[To pass data from your controller, to a Zend_Form, you can utilise the config parameters: $this-&#62;view-&#62;form = new Contact_Edit_Form(array('contactName' =&#62; 'Chris')); This will pass a very simple array to the form, and from within the form, $data = $this-&#62;getAttrib('contactName'); $data will then contain Chris<div class="addthis_toolbox addthis_default_style addthis_" addthis:url='http://www.christatedavies.co.uk/2011/05/20/how-to-pass-data-from-controller-to-zend-form/' addthis:title='How to pass data from Controller to Zend Form ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></description>
			<content:encoded><![CDATA[<p>To pass data from your controller, to a Zend_Form, you can utilise the config parameters:</p>
<pre>$this-&gt;view-&gt;form = new Contact_Edit_Form(array('contactName' =&gt; 'Chris'));</pre>
<p>This will pass a very simple array to the form, and from within the form,</p>
<pre>$data = $this-&gt;getAttrib('contactName');</pre>
<p>$data will then contain <strong>Chris</strong></p>
<p><strong><br />
</strong></p>
<div class="addthis_toolbox addthis_default_style addthis_" addthis:url='http://www.christatedavies.co.uk/2011/05/20/how-to-pass-data-from-controller-to-zend-form/' addthis:title='How to pass data from Controller to Zend Form ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></content:encoded>
			<wfw:commentRss>http://www.christatedavies.co.uk/2011/05/20/how-to-pass-data-from-controller-to-zend-form/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Zend Console &#8211; get values passed</title>
		<link>http://www.christatedavies.co.uk/2011/05/11/zend-console-get-values-passed/</link>
		<comments>http://www.christatedavies.co.uk/2011/05/11/zend-console-get-values-passed/#comments</comments>
		<pubDate>Wed, 11 May 2011 14:27:51 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Zend Framework]]></category>
		<category><![CDATA[CLI]]></category>
		<category><![CDATA[Console]]></category>
		<category><![CDATA[parameters]]></category>
		<category><![CDATA[Zend]]></category>
		<category><![CDATA[zend framework]]></category>

		<guid isPermaLink="false">http://www.christatedavies.co.uk/?p=165</guid>
		<description><![CDATA[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' =&#62; 'test option 1', 'e' =&#62; 'test option 2') ); For instance, &#62; php myScript.php -i OPTION To get the &#8220;OPTION&#8221; string for the -i parameter $arg = $console-&#62;getOption('i'); $arg [...]<div class="addthis_toolbox addthis_default_style addthis_" addthis:url='http://www.christatedavies.co.uk/2011/05/11/zend-console-get-values-passed/' addthis:title='Zend Console &#8211; get values passed ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></description>
			<content:encoded><![CDATA[<p>When using a CLI script with options, I like to use the Zend_Console.</p>
<p>If my options are as follows:</p>
<pre>$console = new Zend_Console_Getopt(
    array(
        'i-s'  =&gt; 'test option 1',
        'e'    =&gt; 'test option 2')
    );</pre>
<p>For instance,</p>
<pre>&gt; php myScript.php -i OPTION</pre>
<p>To get the &#8220;OPTION&#8221; string for the -i parameter</p>
<pre>$arg = $console-&gt;getOption('i');</pre>
<p>$arg will now contain the passed option, but if none was passed, it will be NULL</p>
<p>When outlining the available options that can be used with your script, you use the following syntax:</p>
<pre>long|short  =&gt; description;</pre>
<pre>test|t =&gt; 'Test the script';</pre>
<p>You can use,</p>
<pre>&gt; php myScript.php -t</pre>
<p>or</p>
<pre>&gt; php myScript.php --test</pre>
<p>to run the -test parameter. You can also pass values, such as an integer or a string:</p>
<pre>'test|t=i' =&gt; 'Option with required integer parameter';</pre>
<pre lang="x-western">'test|t-s' =&gt; 'Option with optional string parameter'</pre>
<p>For more information, refer to the Zend Documentation : <a href="http://framework.zend.com/manual/en/zend.console.getopt.introduction.html" target="_blank">http://framework.zend.com/manual/en/zend.console.getopt.introduction.html</a></p>
<div class="addthis_toolbox addthis_default_style addthis_" addthis:url='http://www.christatedavies.co.uk/2011/05/11/zend-console-get-values-passed/' addthis:title='Zend Console &#8211; get values passed ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></content:encoded>
			<wfw:commentRss>http://www.christatedavies.co.uk/2011/05/11/zend-console-get-values-passed/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Zend_Db &#8211; Performing a LIKE search</title>
		<link>http://www.christatedavies.co.uk/2011/01/12/zend_db-performing-a-like-search/</link>
		<comments>http://www.christatedavies.co.uk/2011/01/12/zend_db-performing-a-like-search/#comments</comments>
		<pubDate>Wed, 12 Jan 2011 16:57:17 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[zend framework]]></category>

		<guid isPermaLink="false">http://www.christatedavies.co.uk/?p=128</guid>
		<description><![CDATA[When performing a simple SQL search using Zend_Db_Select, $select-&#62;where('name = ?', 'chris'); But what if you want to do a LIKE search? $select-&#62;where('name LIKE ?', 'chris%'); Simples.<div class="addthis_toolbox addthis_default_style addthis_" addthis:url='http://www.christatedavies.co.uk/2011/01/12/zend_db-performing-a-like-search/' addthis:title='Zend_Db &#8211; Performing a LIKE search ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></description>
			<content:encoded><![CDATA[<p>When performing a simple SQL search using Zend_Db_Select,</p>
<pre>$select-&gt;where('name = ?', 'chris');</pre>
<p>But what if you want to do a LIKE search?</p>
<pre>$select-&gt;where('name LIKE ?', 'chris%');</pre>
<p>Simples.</p>
<div class="addthis_toolbox addthis_default_style addthis_" addthis:url='http://www.christatedavies.co.uk/2011/01/12/zend_db-performing-a-like-search/' addthis:title='Zend_Db &#8211; Performing a LIKE search ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></content:encoded>
			<wfw:commentRss>http://www.christatedavies.co.uk/2011/01/12/zend_db-performing-a-like-search/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Setting up postfix on Ubuntu for mailing from PHP</title>
		<link>http://www.christatedavies.co.uk/2010/10/05/setting-up-postfix-on-ubuntu-for-mailing-from-php/</link>
		<comments>http://www.christatedavies.co.uk/2010/10/05/setting-up-postfix-on-ubuntu-for-mailing-from-php/#comments</comments>
		<pubDate>Tue, 05 Oct 2010 10:42:41 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[IT]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[mail]]></category>
		<category><![CDATA[postfix]]></category>
		<category><![CDATA[terminal]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.christatedavies.co.uk/?p=117</guid>
		<description><![CDATA[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&#8217;ll need to enter some options, like what sort of server you&#8217;re connecting to. I use my companies details in [...]<div class="addthis_toolbox addthis_default_style addthis_" addthis:url='http://www.christatedavies.co.uk/2010/10/05/setting-up-postfix-on-ubuntu-for-mailing-from-php/' addthis:title='Setting up postfix on Ubuntu for mailing from PHP ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></description>
			<content:encoded><![CDATA[<p>To allow your Ubuntu server to send emails from PHP, then you need to install postfix. Postfix is a mailer for *nix platforms.</p>
<p>So, to install it:</p>
<pre>sudo apt-get install postfix</pre>
<p>When this is installing, you&#8217;ll need to enter some options, like what sort of server you&#8217;re connecting to. I use my companies details in here, and this means I need to enter the domain into the origins so that we don&#8217;t get refused mail.</p>
<pre>sudo nano /etc/postfix/main.cf</pre>
<p>Un-comment the line that states myorigin = /etc/mailname</p>
<p>Also, I have to enter the ip address of my mail server in the relayhost section.</p>
<p>CTRL X and save the file.</p>
<p>Now, we need to create the file /etc/mailname</p>
<pre>sudo nano /etc/mailname</pre>
<p>In this empty file, enter the domain name for your mailserver.</p>
<pre>christatedavies.co.uk</pre>
<p>CTRL X and save the file.</p>
<p>Now, just restart postfix:</p>
<pre>sudo /etc/init.d/postfix restart</pre>
<p>Job&#8217;s a goodun.</p>
<div class="addthis_toolbox addthis_default_style addthis_" addthis:url='http://www.christatedavies.co.uk/2010/10/05/setting-up-postfix-on-ubuntu-for-mailing-from-php/' addthis:title='Setting up postfix on Ubuntu for mailing from PHP ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></content:encoded>
			<wfw:commentRss>http://www.christatedavies.co.uk/2010/10/05/setting-up-postfix-on-ubuntu-for-mailing-from-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Zend_Date &#8211; difference between 2 dates</title>
		<link>http://www.christatedavies.co.uk/2010/10/01/zend_date-difference-between-2-dates/</link>
		<comments>http://www.christatedavies.co.uk/2010/10/01/zend_date-difference-between-2-dates/#comments</comments>
		<pubDate>Fri, 01 Oct 2010 15:04:58 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[dates]]></category>
		<category><![CDATA[Zend]]></category>
		<category><![CDATA[zend framework]]></category>

		<guid isPermaLink="false">http://www.christatedavies.co.uk/?p=109</guid>
		<description><![CDATA[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-&#62;setDay(1)-&#62;setMonth(7); //if we are currently after july this [...]<div class="addthis_toolbox addthis_default_style addthis_" addthis:url='http://www.christatedavies.co.uk/2010/10/01/zend_date-difference-between-2-dates/' addthis:title='Zend_Date &#8211; difference between 2 dates ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></description>
			<content:encoded><![CDATA[<p>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.</p>
<pre>
<div id="_mcePaste">//set up the 2 date objects</div>
<div id="_mcePaste">$now = new Zend_Date();</div>
<div id="_mcePaste">$next = new Zend_Date();</div>
<div id="_mcePaste">//we want July 1st</div>
<div id="_mcePaste">$next-&gt;setDay(1)-&gt;setMonth(7);</div>
<div id="_mcePaste">//if we are currently after july this year</div>
<div id="_mcePaste">if ($now-&gt;get(Zend_Date::MONTH) &gt;= 7) {</div>
<div id="_mcePaste">    //we need to work it out til next July</div>
<div id="_mcePaste">    $next-&gt;setYear($now-&gt;get(Zend_Date::YEAR) + 1);</div>
<div id="_mcePaste">}</div>
<div id="_mcePaste">else {</div>
<div id="_mcePaste">    //this july is fine</div>
<div id="_mcePaste">    $next-&gt;setYear($now-&gt;get(Zend_Date::YEAR));</div>
<div id="_mcePaste">}</div>
<div id="_mcePaste">$diff = $next-&gt;sub($now)-&gt;toValue();</div>
<div id="_mcePaste">return $diff / 60 / 60 / 24;</div>
</pre>
<div class="addthis_toolbox addthis_default_style addthis_" addthis:url='http://www.christatedavies.co.uk/2010/10/01/zend_date-difference-between-2-dates/' addthis:title='Zend_Date &#8211; difference between 2 dates ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></content:encoded>
			<wfw:commentRss>http://www.christatedavies.co.uk/2010/10/01/zend_date-difference-between-2-dates/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

