Hi all,

After upgrading from PHP 5.3.8 to 5.4.12 yesterday, along with the associated 
modules and their dependencies, the
following exception was tossed in my ZF 1.12.1 application which connects to 
SQL Server 2008 R2 with FreeTDS on FreeBSD:

    A table must have a primary key, but none was found for table 'Foo'

I tracked the problem down to Zend_Db_Adapter_Pdo_Mssql::describeTable(). On 
line 237, it executes a
query to fetch the column metadata:

        $sql = "exec sp_columns @table_name = " . 
$this->quoteIdentifier($tableName, true);
        $stmt = $this->query($sql);
        $result = $stmt->fetchAll(Zend_Db::FETCH_NUM);

That query works fine and the column data is returned as expected. However, the 
query on 258, which fetches the primary
key metadata, fails:

        $sql = "exec sp_pkeys @table_name = " . 
$this->quoteIdentifier($tableName, true);
        $stmt = $this->query($sql);
        $primaryKeysResult = $stmt->fetchAll(Zend_Db::FETCH_NUM);

$prmaryKeysResult is empty after the fetchAll(). There are no errors in any 
logs and the FreeTDS debug log shows the
results coming back from the server.

After playing around ab it, I found that if I add an 'unset($stmt);' after the 
first query is fetched, the second query
returns the expected results.

What might cause this behavior? What's the next step in troubleshooting? I'm 
utterly at a loss on this one.

Thanks,

-Brad

-- 
List: [email protected]
Info: http://framework.zend.com/archives
Unsubscribe: [email protected]


Reply via email to