Hi folks,

i have a stupid problem here, when i try to quote an sql statement like:

    SELECT COUNT(*) FROM $tablename

with the code

    $db->query('SELECT COUNT(*) FROM ?', array($tablename));

i get the following log output

    *[Exception]*: Zend_Db_Statement_Exception
    *[Message]*: 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
    *[File]*:
    
/var/www/mystuff/apps/library/ZendFramework-1.0.1/library/Zend/Db/Statement/Pdo.php
    *[Line]*: 68

To be sure it's now how i use the quoting i've tried an SQL statement
with phpMyAdmin

    SELECT COUNT(*) FROM `tableName`;

which is working, so the quotes can be used there.

I hope someone here can help me, i've talked on #zftalk but found no
solution.
I've tried allmost all methods to quote parameters (the ? thing, named
parameters with different methods or classes like zend_db_statement).


best regards,
Steven Truppe




Reply via email to