zend-framework
How do you make Zend Framework NOT render a view/layout when sending an AJAX response?
Call this code from within whatever Action(s) is/are going to be sending AJAX responses: $this->_helper->layout->disableLayout(); $this->_helper->viewRenderer->setNoRender(TRUE); This disables the Layout engine for that action, and it turns off automatic view rendering for that action. You can then just “echo” whatever you want your AJAX output to be, without worrying about the normal view/layout stuff getting … Read more
Is there a way to do an “INSERT…ON DUPLICATE KEY UPDATE” in Zend Framework 1.5?
I worked for Zend and specifically worked on Zend_Db quite a bit. No, there is no API support for the ON DUPLICATE KEY UPDATE syntax. For this case, you must simply use query() and form the complete SQL statement yourself. I do not recommend interpolating values into the SQL as harvejs shows. Use query parameters. … Read more
Zend Framework: How do I remove the decorators on a Zend Form Hidden Element?
For hidden field you need only one decorator – ViewHelper: $field = new Zend_Form_Element_Hidden(‘id’); $field->setDecorators(array(‘ViewHelper’)); This will render only the input field, without Dt-Dd wrapper and label.
Set Application_ENV via virtual host config and read this in PHP
Since SetEnv set’s the value to Apache’s environment, you can get it with apache_getenv — Get an Apache subprocess_env variable or just getenv — Gets the value of an environment variable If you look at public/index.php in a ZF project, you will see ZF uses getenv: // Define application environment defined(‘APPLICATION_ENV’) || define(‘APPLICATION_ENV’, (getenv(‘APPLICATION_ENV’) ? … Read more
Running MySQL *.sql files in PHP
This question comes up from time to time. There’s no good solution for running a .sql script directly from PHP. There are edge cases where statements common in a .sql script can’t be executed as SQL statements. For example, the mysql tool has builtin commands that are not recognized by the MySQL Server, e.g. CONNECT, … Read more