Krumo looks like a very useful tool for debugging; replacing print_r() and var_dump() functions. I first found out about this class from the comments by kaloyan at gmail dot com in the var_dump() page in http://www.php.net/var_dump
Zend_Form: How to set message for NotEmpty when setRequired(true)
When, in a subclass of Zend_Form, a Zend_Form_Element is setRequired(true) it automatically adds a NotEmpty validator using the default message. To override the default message add a NotEmpty validator at the top of the list of validators and set breakChainOnFailure to true.
$username = new Zend_Form_Element_Text('username');
$username->setLabel('Username')
->setRequired(true)
->addFilter('StripTags')
->addFilter('StringTrim')
->addValidator('NotEmpty', true, array(
'messages' => array(
'isEmpty' => 'Username is required'
)
))
->addValidator('Alnum', false, array(
'messages' => array(
'notAlnum' => 'Use only letters and numbers'
)
));
The solution, given by Matthew Weier O’Phinney, was found in the following thread:
Related threads:
how to set error message for Required form validator?
Zend_Form_Element NotEmpy validation when required is set to true
The validation failure message keys, i.e. isEmpty, notAlnum, can be found in the API Docs or by directly reading the validation class file in the library/Zend/Validate folder.
Cannot execute queries while other unbuffered queries are active
Cannot execute queries while other unbuffered queries are active
Can’t execute subsequent query after multiple queries from same Pdo_Mysql->exec() call
Can’t execute multiple stored procedures with Pdo_Mysql
Using the following code found in the Zend Framework Quickstart: Create a Model and Database Table
// this block executes the actual statements that were loaded from // the schema file. try { $schemaSql = file_get_contents('./schema.sqlite.sql'); // use the connection directly to load sql in batches $dbAdapter->getConnection()->exec($schemaSql); echo PHP_EOL; echo 'Database Created'; echo PHP_EOL; if ($withData) { $dataSql = file_get_contents('./data.sqlite.sql'); // use the connection directly to load sql in batches $dbAdapter->getConnection()->exec($dataSql); echo 'Data Loaded.'; echo PHP_EOL; } } catch (Exception $e) { echo 'AN ERROR HAS OCCURED:' . PHP_EOL; echo $e->getMessage() . PHP_EOL; return false; }
Note that $dbAdapter->getConnection()->exec() gets called twice.
I encountered this issue when calling Pdo_Mysql->exec() or in the Zend Framework calling $dbAdapter->getConnection()->exec($schemaSql) one after the other.
One way to prevent the error was to call $dbAdapter->closeConnection() after each exec call. Another way I worked around this problem was to just execute the $schemaSql and the $dataSql in one exec call like below;
$schemaSql = file_get_contents('schema.sql', 1);
$dataSql = file_get_contents('data.sql', 1);
// use the connection directly to load sql in batches
$dbAdapter->getConnection()->exec($schemaSql . $dataSql);