mysql - Simple SQL syntax error in fetchRow() Zend Framework -


i got simple instruction this:

    $db = zend_db_table::getdefaultadapter(); $select = $db->select(); $select         ->from(array("b" => "barcos"))         ->join(array("i" => "imagens"), 'b.id = i.barcoid')         ->where("b.id = {$idembarcacao}")         ->group("i.barcoid");  $this->view->anuncio = $db->fetchrow($select); 

and returns error

message: sqlstate[42000]: syntax error or access violation: 1064 have error in sql syntax; check manual corresponds mysql server version right syntax use near ')' @ line 1 

it driving me crazy, because in particular page returns error, in other pages fine. database correctly populated. shoud return error. in advance.

please try way

$db = zend_db_table::getdefaultadapter(); $select = $db->select(); $select         ->from(array("b" => "barcos"))         ->join(array("i" => "imagens"), 'b.id = i.barcoid')        // ->where("b.id = {$idembarcacao}")         ->where("b.id = ?", $idembarcacao)         ->group("i.barcoid");  $this->view->anuncio = $db->fetchrow($select); 

you can use ->where("b.id = ?", $idembarcacao) instead of ->where("b.id = {$idembarcacao}")


Comments