#25311 [Asn->Bgs]: DB_Common::prepare() returns 0
| From: | cox@php.net | Date: | Fri, 29 Aug 2003 13:49:24 +0000 |
| Subject: | #25311 [Asn->Bgs]: DB_Common::prepare() returns 0 | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-20823@lists.php.net to get a copy of this message | ||
ID: 25311
Updated by: cox@php.net
Reported By: jamert at one dot lv
-Status: Assigned
+Status: Bogus
Bug Type: PEAR related
Operating System: Red Hat Linux release 6.2
PHP Version: 4.3.3
Assigned To: cox
New Comment:
Only backends how natively support prepare/execute will return a
"resource". When it's emulated it just returns an interger we use as
index.
It's a documentation problem not related to the code.
Previous Comments:
------------------------------------------------------------------------
[2003-08-29 07:20:06] jamert at one dot lv
Description:
------------
Greetings!
I have an interesting problem, using prepare() method of interface
class DB_Common in package PEAR DB (last version, 1.5.0RC1).
According to documentation, it must return resource, but it returns 0!
So, I cannot use "execute()". There's no even error!
Though, connection is established correctly, and the queries work
properly, using such methods as query, getRow, etc.
If I use query or get* methods as workaround, for example:
$DB->query("SELECT type_name FROM FOO WHERE ?=?", array("type_id",
3));
, then everything goes fine.
Reproduce code:
---------------
<?
require_once ("common/conf/config.inc.php"); // Here the $CONFIG array
is defined
require_once ("DB.php");
$db_host = $CONFIG['db']['host'];
$db_type = $CONFIG['db']['dbtype'];
$db_name = $CONFIG['db']['dbname'];
$db_user = $CONFIG['db']['user'];
$db_pwd = $CONFIG['db']['password'];
$dsn = "$db_type://$db_user:$db_pwd@$db_host/$db_name";
$DB = DB::connect($dsn);
if (DB::isError($DB))
die ($DB->getMessage());
$prep_stmt = $DB->prepare("SELECT type_name FROM FOO WHERE
type_id=?");
if (DB::isError($DB))
die ($DB->getMessage()); // Just to be sure that PEAR still thinks
that all is OK
echo "PREPARED STATEMENT: '$prep_stmt', type is " .
gettype($prep_stmt);
?>
Expected result:
----------------
The query handle, of type 'resourse', according to documentation.
(I don't know the right output text to be, just because I've never got
one).
Actual result:
--------------
PREPARED STATEMENT: '0', type is integer
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=25311&edit=1