Welcome, Guest. Register Now!
   
Mark Forums Read Mark Forums Read Mark Forums Read


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-08-2008, 11:57 AM
Junior Member
 
Join Date: May 2008
Posts: 1
Default Exception 'Zend_Db_Statement_Exception'

I don't know how this error appears. I have many controllers that has the same logic but only in some this error appear.
Example:

I'm deleting a photo from gallery in which goes order by field 'position'. If I'm deleting the last, there is no problem. When I'm deleting other I must decrement position of all photos after. So if the photo delete link is clicked, there is invoked this action:

Code:
public function deleteAction()
    {
        $id = $this->getRequest()->getParam('id');
        $photos = new Photos();
        
        $where = $photos->getAdapter()->quoteInto('id = ?', $id);
        $photo = $photos->fetchRow($where);
        
        $position = $photo->position;
        
        $count = $photos->fetchAll()->count();
        
        if($position == $count)
        {
            $where = $photos->getAdapter()->quoteInto('id = ?', $id);
            $photos->delete($where);
        }
        else
        {
            $where = $photos->getAdapter()->quoteInto('id = ?', $id);
            $photos->delete($where);
            
            for($i = $position + 1; $i <= $count; $i++)

            {

                $where = $photos->getAdapter()->quoteInto('position = '.$i);

                $data = array();

                $data['position'] = $i - 1;

                $photos->update($data, $where);

            }
        }
        
        $this->_redirect('admin/prodgallery');
    }
And it is producting this error:


Fatal error: Uncaught exception 'Zend_Db_Statement_Exception' with message 'SQLSTATE[HY093]: Invalid parameter number: no parameters were bound' in /home/httpd/html/shop/library/Zend/Db/Statement/Pdo.php:238 Stack trace: #0 /home/httpd/html/shop/library/Zend/Db/Statement.php(283): Zend_Db_Statement_Pdo->_execute(Array) #1 /home/httpd/html/shop/library/Zend/Db/Adapter/Abstract.php(406): Zend_Db_Statement->execute(Array) #2 /home/httpd/html/shop/library/Zend/Db/Adapter/Pdo/Abstract.php(206): Zend_Db_Adapter_Abstract->query(Object(Zend_Db_Table_Select), Array) #3 /home/httpd/html/shop/library/Zend/Db/Table/Abstract.php(1185): Zend_Db_Adapter_Pdo_Abstract->query(Object(Zend_Db_Table_Select)) #4 /home/httpd/html/shop/library/Zend/Db/Table/Abstract.php(1040): Zend_Db_Table_Abstract->_fetch(Object(Zend_Db_Table_Select)) #5 /home/httpd/html/shop/application/controllers/AdminController.php(423): Zend_Db_Table_Abstract->fetchAll(Object(Zend_Db_Table_Select)) #6 /home/httpd/html/shop/library/Zend/Controller/Action.php(502): AdminCon in /home/httpd/html/shop/library/Zend/Db/Statement/Pdo.php on line 238

I was searching a lot to solve this. I've found many simmilar errors but in cases where a strange stirngs were binded. In my case we talk about simple numbers...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 05-09-2008, 08:39 PM
Junior Member
 
Join Date: Oct 2007
Posts: 21
Default

This usually means that the params to be bound were null or not specified.

The error probably comes from this line:

PHP Code:
$where $photos->getAdapter()->quoteInto('id = ?'$id); 
It's wise in your scripts to test for anything you retrieve with getParam();

e.g.

PHP Code:
public function deleteAction()
    {
        
$id $this->getRequest()->getParam('id');

        if (!
$id){
             
//error
        
}
//...

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 11:04 AM.