What a nice Oracle feature: RETURNING INTO Clause

April 27, 2010 by Reboot · Leave a Comment 

Is handy to fetch the number of rows affected by an insert, update or delete statement!

RETURNING INTO Clause

Phrase of the Day: One-Trick Pony.

April 27, 2010 by Reboot · Leave a Comment 

Wiktionary: “One-Trick Pony”

And a colleague of mine likes to wear this priceless t-shirt: More Dots

Installing PHPUnit to run phpunit.xml for Zend Server 5.3.1

April 22, 2010 by Reboot · Leave a Comment 

1. Install PEAR by running go-pear.bat

if it starts to complain about: “… does not have a signature …” change the go-pear.bat to the following:

@ECHO OFF
set PHP_BIN=php.exe
%PHP_BIN% -d output_buffering=0 -d phar.require_hash=0 PEAR\go-pear.phar
pause

In windows the last part of the output will be something like:

Would you like to alter php.ini ? [Y/n] :

php.ini include_path updated.

Current include path : .
Configured directory : D:\Zend Server 5.3.1\ZendServer\bin\pear
Currently used php.ini (guess) : D:\Zend Server 5.3.1\ZendServer\etc\php.ini
Press Enter to continue:

** WARNING! Old version found at D:\Zend Server 5.3.1\ZendServer\bin, please remove it or be sure to use the new d:\zend
server 5.3.1\zendserver\bin\pear.bat command

The ‘pear’ command is now at your service at d:\zend server 5.3.1\zendserver\bin\pear.bat

* WINDOWS ENVIRONMENT VARIABLES *
For convenience, a REG file is available under D:\Zend Server 5.3.1\ZendServer\bin\PEAR_ENV.reg .
This file creates ENV variables for the current user.

Double-click this file to add it to the current user registry.

2. Update pear:

pear channel-update pear.php.net

and

pear upgrade pear

3. Install PHPUnit via PEAR by running:

pear channel-discover pear.phpunit.de

and

pear install phpunit/PHPUnit

see also: Chapter 3. Installing PHPUnit

TIP: Get the proper code completion in Zend Framework.

April 19, 2010 by Reboot · Leave a Comment 

Some of the standard code completions don’t work properly because various Zend Framework classes redirect method calls by using the magic method “__call($method, array $options)”. For example Zend_Translate does not include the addTranslation method but redirects the call to the applied adapter. You can add a document property which enables the correct code completion. Unfortunately it will only complete the adapter’s methods then, but the adapter does include the methods which you probably want to see completed/documented. The question remains if the whole magic method redirection is a nice way to implement an adapter pattern.

/* @var $translate Zend_Translate_Adapter_Array */
$translate = new Zend_Translate('Zend_Translate_Adapter_Array', $us, 'en_US');
$translate->addTranslation($nl, 'nl');

TIP: Missing Zend Framework Errors?!?

April 19, 2010 by Reboot · Leave a Comment 

If you happen to use Zend tool to create a project and globally turn off the view rendering in your control logic, the error controller will also neglect to show a stack-trace or error details. Add the following code to the error controller just in case.

public function __construct(Zend_Controller_Request_Abstract $request, Zend_Controller_Response_Abstract $response, array $invokeArgs = array()) {
	parent::__construct($request, $response, $invokeArgs);
	$this->getFrontController ()->setParam ( "noViewRenderer", false );
}

It’s also better to disable the view rendering for specific controller actions and not globally, hence the Zend Framework documentation explains it best:

Class FooController extends Zend_Controller_Action {
	public function init() {
		// Local to this controller only; affects all actions,
		// as loaded in init:
		$this->_helper->viewRenderer->setNoRender ( true );

		// Globally:
		$this->_helper->removeHelper ( 'viewRenderer' );

		// Also globally, but would need to be in conjunction with the
		// local version in order to propagate for this controller:
		Zend_Controller_Front::getInstance ()->setParam ( 'noViewRenderer', true );
	}
}

More detailed information at:
Action Controllers

TIP: Get rid of “It is not safe to rely on the system’s timezone settings.”

April 8, 2010 by Reboot · Leave a Comment 

Warning: strtotime() [function.strtotime]: It is not safe to rely on the system’s timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier.

; Copy this line into the php.ini
; http://php.net/manual/en/timezones.php
date.timezone = “Europe/Amsterdam”