RE: [PEAR] getOne problem
| From: | Gigabyte | Date: | Sat, 01 Mar 2003 04:04:59 +0000 |
| Subject: | RE: [PEAR] getOne problem | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-4011@lists.php.net to get a copy of this message | ||
How does that solve the problem?
Are you saying that anytime you do a getOne, you first do a count on
that column/row?
That seems way to wrong! It should return a result of 0, not die like
it does.
-mh
-----Original Message-----
From: Adam Russell [mailto:arussell@northwestern.edu]
Sent: Friday, February 28, 2003 4:44 PM
To: pear-general@lists.php.net
Subject: Re: [PEAR] getOne problem
I had always assumed this behavior was by design, and have always dealt
with
it like this:
$dbh->getOne("select count(id) from login where name="bob");
--
Adam Russell
Northwestern University
----- Original Message -----
From: "Gigabyte" <gigabyte@superdudes.net>
To: "'Rich Payne'" <rdp@talisman.mv.com>
Cc: "'Pear-General-Help'" <pear-general@lists.php.net>
Sent: Friday, February 28, 2003 3:55 PM
Subject: RE: [PEAR] getOne problem
> Its valid -- I have 10 other queries running fine... just getOne.
> Note: This problem ONLY happens if getOne returns NO results.
>
> -mike
>
> -----Original Message-----
> From: Rich Payne [mailto:rdp@talisman.mv.com]
> Sent: Monday, February 24, 2003 1:32 PM
> To: Gigabyte
> Cc: Pear-General-Help
> Subject: RE: [PEAR] getOne problem
>
>
> Looks like $dbh in not a valid database handle then.
>
> what does a var_dump($dbh) return?
>
> --rdp
>
>
> On Mon, 24 Feb 2003, Gigabyte wrote:
>
> > the sql query i gave is actually just a dummy one. the query itself
> is
> > correct (all the "'s in the right spot) -- and if i run the query
from
> the
> > mysql command line:
> >
> > mysql> SELECT id from login where name = 'bob';
> > Empty set (0.00 sec)
> >
> > But when that same query is run from getOne (as all i want to return
> is the
> > id) -- and if it exists, return ID, if not, return 0 :
> >
> > function getCookieID ($name=0) {
> > GLOBAL $dbh;
> > $sql = "SELECT id from login where name = '$name'";
> > //error_log("getCookieID ".$sql);
> > $res = $dbh->getOne($sql);
> > if ($res > 0) {
> > return $res;
> > } else {
> > return 0;
> > }
> > }
> >
> >
> > Error Returned:
> >
> > [24-Feb-2003 13:01:03] PHP Fatal error: Call to a member function
on
> a
> > non-object in /xxx/login.class on line 15
> >
> > {line 15 is $res = $dbh->getOne($sql); }
> >
> >
> >
> > -----Original Message-----
> > From: David DiMaria [mailto:ddimaria@eagledirect.com]
> > Sent: Monday, February 24, 2003 1:21 PM
> > To: 'Gigabyte'; Pear-General-Help
> > Subject: RE: [PEAR] getOne problem
> >
> >
> > I'm not sure if this is your problem, but your code:
> >
> > $dbh->getOne("select id from login where name="bob");
> >
> > may need to be changed to:
> >
> > $dbh->getOne("select id from login where name='bob'");
> >
> > -David DiMaria
> >
> > -----Original Message-----
> > From: Gigabyte [mailto:gigabyte@superdudes.net]
> > Sent: Monday, February 24, 2003 2:15 PM
> > To: Pear-General-Help
> > Subject: [PEAR] getOne problem
> >
> >
> > I seem to be having issues with getOne.
> > $dbh->getOne("select id from login where name="bob");
> >
> > If I send an sql query that returns an Empty Set, it comes back with
> the
> > following error:
> > Call to a member function on a non-object
> >
> > any suggestions?
> >
> > -Mike
> >
> >
> > --
> > PEAR General Mailing List (http://pear.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> > --
> > PEAR General Mailing List (http://pear.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
> > --
> > PEAR General Mailing List (http://pear.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
>
> Rich Payne
> http://talisman.mv.com
> rdp at talisman dot mv dot com
>
>
> --
> PEAR General Mailing List (http://pear.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
PEAR General Mailing List (http://pear.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php