A web developer's blog. PHP, MySQL, CakePHP, Zend Framework, Wordpress, Code Igniter, Django, Python, CSS, Javascript, jQuery, Knockout.js, and other web development topics.

Zend_Db Changing Fetch Mode

I love this, since I do not have to type [' and '] at the end of each field. Typing -> is easier!

   $db = Zend_Registry::get('db');
   $result = $db->fetchAll("SELECT * FROM user_roles");
   foreach($result AS $row) {
      echo $row->fieldA; //instead of the usual $row['fieldA']
      echo $row->fieldB; //instead of the usual $row['fieldA']

This is also documented in my wiki.

This entry was posted in General and tagged , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>