I'm using Zend and I have the following function:
public function getChamado($id) {
try {
$cols = array(
'id', 'titulo', 'descricao', 'fk_status', 'fk_local',
'fk_tipo', 'created', 'modified', 'finished', 'fk_usuario',
'fk_restricao', 'fk_prioridade'
);
$sql = $this->getDefaultAdapter()
->select()
->from($this->_name, $cols)
->where('id = ?', $id);
return $this->fetchRow($sql);
} catch(Exception $e){
echo $e->getMessage(); die;
}
}
It generates this beautiful and perfect query:
SELECT
'tbl_chamado'.'id',
'tbl_chamado'.'titulo',
'tbl_chamado'.'descricao',
'tbl_chamado'.'fk_status',
'tbl_chamado'.'fk_local',
'tbl_chamado'.'fk_tipo',
'tbl_chamado'.'created',
'tbl_chamado'.'modified',
'tbl_chamado'.'finished',
'tbl_chamado'.'fk_usuario',
'tbl_chamado'.'fk_restricao',
'tbl_chamado'.'fk_prioridade'
FROM
'tbl_chamado'
WHERE
(id = '1')
however when running it gives the following error:
SQLSTATE [42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
All variables are correct, the query generated is the same as above. Running directly on the bank it carries the data normally.
Was there a detail I let pass?