RSS - Latest posts Posts Tagged ‘php’

Home » Tags » php
6Mar
2010

Multiple changes and a delete on same object in doctrine

If you want to make several different changes to a doctrine record object you might find yourself slightly puzzled when it comes to deleting related objects.

$user['Address']->delete();
$user['Address']->state(Doctrine_Record::STATE_LOCKED);
(...)
$user->save();

It seems that unless you set the state the save later on still sees an initialized (though empty!) relation.

Categories:

16Dec
2009

Zend_Date time part and GMT

If you live in the UK you might have a surprise waiting in store for you if you use Zend_Date for the time part only. For a while I even thought this was a bug, however digging deeper has shown that actually it’s Zend_Date that is right, in a way at least.

When setting a time before 1972 - this is 1970 and 1971 the time part will not be shifted in the UK locale as DST was only introduced in 1972!

This means if you are only calculating times and need the appropriate time adjustment you will need to set a date as no date part in Zend_Date means 1st Jan 1970.

Categories:

30Jul
2009

Autloading modular forms & models in Zend Framework 1.8

It’s not really obvious with the error messages you get, but using a thing like Form_Login does not work out of the box with a modular structure. Which is slightly surprising considering that it’s inside the default module.

I have found examples like the second one below, but no one mentions that you actually declare the default namespace too for everything to work.

$autoloader = new Zend_Application_Module_Autoloader(array(
	'namespace' => '',
	'basePath'  => APPLICATION_PATH .'/modules/default',
	'resourceTypes' => array (
		'form' => array(
		'path' => 'forms',
		'namespace' => 'Form',
    ),
	'model' => array(
		'path' => 'models',
		'namespace' => 'Model',
    	),
    )
));

$autoloader = new Zend_Application_Module_Autoloader(array(
	'namespace' => 'Admin_',
	'basePath'  => APPLICATION_PATH .'/modules/admin',
	'resourceTypes' => array (
		'form' => array(
		'path' => 'forms',
		'namespace' => 'Form',
    ),
	'model' => array(
		'path' => 'models',
		'namespace' => 'Model',
    	),
    )
));

Categories:

9May
2009

Doctrine Many To Many With Extra Fields

Recently I have started using Doctrine with Zend Framework. Most of the time it is great, but sometimes I get stuck on this or that issue. Most of my problems so far have been connected with the Many to Many relationship. Here are a few tips I learned the hard way. (more…)

Categories:

22Apr
2009

Zend_Db_Select multiple table joins explained

It sounds like a simple task - retrieve the result from a join SQL query. Unusually you can even find documentation on the official Zend Framework site explaining how to put together a query that will return the results from a JOIN query. Unfortunately when it actually comes to putting theory into practice any Zend newcomer can run into several problems. (more…)

Categories: