php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #25311 DB_Common::prepare() returns 0
Submitted: 2003-08-29 07:20 UTC Modified: 2003-08-29 08:49 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: jamert at one dot lv Assigned: cox (profile)
Status: Not a bug Package: PEAR related
PHP Version: 4.3.3 OS: Red Hat Linux release 6.2
Private report: No CVE-ID: None
 [2003-08-29 07:20 UTC] 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

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-08-29 08:49 UTC] cox@php.net
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.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 12:01:31 2024 UTC