ZF-3116: Zend_Db_Table_Row_Abstract->save() Fail on _refresh() "Incorrect syntax near ')'"

Description

Using SQL Server 2000, and Zend_Db_Adapter_Pdo_Mssql

Here's the application code:


try
{
    //$email_requests_table is an instance of a Zend_Db_Table_Abstract extension
    $new = $email_requests_table->createRow(array(
        'oc_id' => $input['oc_id'][$i],
        'EmailAddress' => $input['EmailAddress'],
        'PersonName' => $input['PersonName'],
    ));
    $new->save();
}
catch(Zend_Db_Table_Row_Exception $e)
{
    header("content-type: text/plain"); die(print_r($new, true) . "\n" . print_r($e, true));
}

Using a SQL Profiler I was able to apprehend that the correct insert is performed, but during _refresh() the following invalid query is sent: {quote} SELECT "vp_Email_Requests".* FROM "vp_Email_Requests" WHERE ("TblPK" = 181) SELECT * FROM (SELECT TOP 1 * FROM {color:red} (){color} AS inner_tbl) AS outer_tbl {quote} Which is sending an error back "Incorrect syntax near ')'" (highlighted in red)

I'm certain my application code is right, because I've done similar tasks using a MySQL adapter. I'm thinking this is a Mssql adapter related bug.

Comments

This is what $email_requests_table is an instance of

Please evaluate and categorize as necessary.

It looks like this bug may be coming from line 1044 of Zend/Db/Select.php


$this->_adapter->limit('', $count, $offset)

It's calling the limit function, but passing an empty $sql variable, so the result is that the subselect is empty.

This has been fixed by SVN8784

Changing issues in preparation for the 1.7.0 release.