Solved

PHP Fatal error: Call to undefined method DB_Error::query()

Posted on 2007-11-29
9
6,029 Views
Last Modified: 2013-12-12
I'm using Zend Core for Oracle. I have a file called PTutil.php connects to oracle DB, query the DB and display results.

Currently I'm unable to make work due to this error:

PHP Fatal error:  Call to undefined method DB_Error::query() in ../Phonetimes/PTutil.php on line 192

The line 192 is this:

$res =& $db->query($query);

PEAR is installed and working fine.

I did some google search on this error, and tried what were suggested but still have the same error.

Can you please help me solve this error?

Thanks
0
Comment
Question by:bprof2007
  • 5
  • 4
9 Comments
 
LVL 21

Expert Comment

by:nizsmo
ID: 20376382
try:

$res =& $db->sql_query($query);
0
 
LVL 1

Author Comment

by:bprof2007
ID: 20376418
Thank I've tried it and got this error:

PHP Fatal error:  Call to undefined method DB_Error::sql_query() in ../PTutil.php on line 193

0
 
LVL 21

Expert Comment

by:nizsmo
ID: 20378016
which wrapper class are you using for mysql functions?
0
 
LVL 1

Author Comment

by:bprof2007
ID: 20383634
I'm using a file called DB.php here are some info from the file itself about what it does?

/**
 * Database independent query interface
 *
 * PHP versions 4 and 5
 *
 * LICENSE: This source file is subject to version 3.0 of the PHP license
 * that is available through the world-wide-web at the following URI:
 * http://www.php.net/license/3_0.txt.  If you did not receive a copy of
 * the PHP License and are unable to obtain it through the web, please
 * send a note to license@php.net so we can mail you a copy immediately.
 *
 * @category   Database
 * @package    DB
 * @author     Stig Bakken <ssb@php.net>
 * @author     Tomas V.V.Cox <cox@idecnet.com>
 * @author     Daniel Convissor <danielc@php.net>
 * @copyright  1997-2005 The PHP Group
 * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
 * @version    CVS: $Id: DB.php,v 1.80 2005/02/16 02:16:00 danielc Exp $
 * @link       http://pear.php.net/package/DB
 */

I didn't work with OO in PHP before. :(
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 21

Expert Comment

by:nizsmo
ID: 20386427
The error is basically due to the function query() being undefined. Why dont' you use straight off the oci8 methods. And then you can use oci_fetch_array() to fetch out any results you want, much like mysql functions.

$conn = oci_connect('scott', 'tiger', 'orcl');

$query = 'SELECT myclob FROM mytable WHERE mykey = :mykey';
 

$stid = oci_parse ($conn, $query);

oci_bind_by_name($stid, ":mykey", $mykey, 5);

oci_execute($stid, OCI_DEFAULT);

Open in new window

0
 
LVL 1

Author Comment

by:bprof2007
ID: 20397786
Thanks much nizsmo for the code.

Can you please explain to me what is mykey in this line:

oci_bind_by_name($stid, ":mykey", $mykey, 5);

I'm not sure why its needed.

I'm also getting this error:

Fatal error: Call to a member function fetchInto() on a non-object in /usr/local/Zend/apache2/htdocs/test.php on line 93

93:while ($res->fetchInto($row)) {

I'm really n00b in pear and connecting to oracle.


0
 
LVL 21

Expert Comment

by:nizsmo
ID: 20398796
not too sure what fetchInto does? but have you set the $row variable?
You can fetch the results from the OCI connection using this function:
http://php.net/manual/en/function.oci-fetch-array.php

Also in case you are still wondering about the oci_bind_by_name() function:
http://php.net/function.oci_bind_by_name

Hope this helps!
0
 
LVL 21

Accepted Solution

by:
nizsmo earned 250 total points
ID: 20398801
Forgot to mention, in those sites above there are some nice examples, especially some full examples in oci_fetch_array() link, which will probably answer your questions :)
0
 
LVL 1

Author Comment

by:bprof2007
ID: 20458286
Thanks a lot
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now