From:             uwendel at mysql dot com
Operating system: Linux
PHP version:      5.3CVS-2008-02-19 (CVS)
PHP Bug Type:     PDO related
Bug description:  PDO->query ('SELECT ...', PDO::FETCH_COLUMN, -1) - error or 
not?

Description:
------------
What is PDO->query('SELECT ...', PDO::FETCH_COLUMN, $colno) supposed to do
if you pass an invalid column number in $colno, e.g.:

$stmt = $pdo->query('SELECT only_column FROM test', PDO::FETCH_COLUMN,
-1);

My preference would be to make PDO bail about the invalid offset. However,
I do not know if this would work with all drivers. So, maybe its even
technically not possible to make PDO emit a warning if the requested column
is not available.

In any case, I ask to update the manual and tell people about this edge
case.


Reproduce code:
---------------
[EMAIL PROTECTED]:~/php53> sapi/cli/php -r '$pdo=new
PDO("sqlite:/tmp/foo.db"); @$pdo->exec("DROP TABLE test");
$pdo->exec("CREATE TABLE test(id INT)"); $pdo->exec("INSERT INTO test(id)
VALUES (1)"); var_dump($pdo->query("SELECT id FROM test",
PDO::FETCH_COLUMN, -1)->fetchAll());'
array(0) {
}

(Same with MySQL)

Expected result:
----------------
If possible, make PDO bail out when calling query() with invalid column
offsets. If that's not possible for technical reasons, please consider
having a note about this in the manual.


-- 
Edit bug report at http://bugs.php.net/?id=44171&edit=1
-- 
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=44171&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): 
http://bugs.php.net/fix.php?id=44171&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=44171&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=44171&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=44171&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=44171&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=44171&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=44171&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=44171&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=44171&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=44171&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=44171&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=44171&r=globals
PHP 4 support discontinued:   http://bugs.php.net/fix.php?id=44171&r=php4
Daylight Savings:             http://bugs.php.net/fix.php?id=44171&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=44171&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=44171&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=44171&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=44171&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=44171&r=mysqlcfg

Reply via email to