Page 1 of 1

Zend_Db issue with fetchAssoc

Posted: Tue Dec 08, 2009 11:56 am
by alex.barylski
I have the following code:

Code: Select all

//$this->db->setFetchMode(Zend_Db::FETCH_OBJ);
$results = $this->db->fetchAssoc('SELECT * FROM sites WHERE id = ?', 1);
 
I am getting the following results:

Code: Select all

Array
(
    [1] => Array
        (
            [id] => 1
            [name] => default shop
            [description] => Default shop.
            [base_url] => http://localhost/
            [warehouse_filters_enabled] => 0
            [category_filters_enabled] => 0
            [view_directory] => default
            [app_folder] => shop_main
            [session_name] => shopmain
            [is_down] => 0
            [down_time_msg] => 
            [enable_cutomer_category_filters] => 1
        )
 
)
 
The error here (if not obvious) is that I am selecting a single record and should be able to return the details like:

Code: Select all

return $results[0];
Which I cannot do because the index is ONE???

What am I doing wrong?

Cheers,
Alex

Re: Zend_Db issue with fetchAssoc

Posted: Tue Dec 08, 2009 3:15 pm
by John Cartwright
The index is the primary key, so you'll either need to handle the logic in your model (array_shift() or alike) to use the fetchRow() method.