#42935 [Opn]: pdo fails to identify data type

From: Date: Thu, 11 Oct 2007 21:29:53 +0000
Subject: #42935 [Opn]: pdo fails to identify data type
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-118430@lists.php.net to get a copy of this message
 ID:               42935
 User updated by:  denis at mesoconcepts dot com
-Summary:          pdo doesn't understand sql?
 Reported By:      denis at mesoconcepts dot com
 Status:           Open
 Bug Type:         PDO related
 Operating System: freebsd
 PHP Version:      5.2.4
 New Comment:

further investigation led us to identify this query as a solution:

$dbs = $dbh->prepare(' SELECT	1 WHERE	(?)::int4 IS NOT NULL ');

nonetheless, it would be sweet if pdo identified the first as an
integer indeed.


Previous Comments:
------------------------------------------------------------------------

[2007-10-11 21:23:12] denis at mesoconcepts dot com

was of course meant: when something is __not__ null

------------------------------------------------------------------------

[2007-10-11 21:20:53] denis at mesoconcepts dot com

Description:
------------
using select 1 where something is null returns an empty array

D.

Reproduce code:
---------------
try
{
	$dbh =& new PDO(
		'pgsql:host=' . $db_host . ';dbname=' . $db_name,
		$db_user,
		$db_pass
		);
}

$dbs = $dbh->prepare("
	SELECT	1
	WHERE	? IS NOT NULL
	");

$dbs->execute(array(1));

$res = $dbs->fetchAll();

var_dump($res);

Expected result:
----------------
a row

Actual result:
--------------
no rows


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=42935&edit=1


Thread (5 messages)

« previous php.bugs (#118430) next »