DB - Query works on command line, not with PEAR::DB?
| From: | Nelson Goforth | Date: | Tue, 15 Feb 2005 18:11:45 +0000 |
| Subject: | DB - Query works on command line, not with PEAR::DB? | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-17536@lists.php.net to get a copy of this message | ||
I'm trying to do a straightforward UPDATE query using PEAR::DB, and getting the 'unknown error' error.
The SQL statement I'm providing (see below) executes when I go through phpMyAdmin AND when I paste the statement in on the command line. But when I try to run it with
$stmt = "UPDATE contacts..."; // as below
$result =& $link->query($stmt);
I get an error. I don't like the auto prepare and execute methods as I can't see the actual SQL code that it's preparing. I tried this also using prepare and execute:
$sth = $link->prepare($stmt);
if (DB::isError($sth)) {
die($sth->getMessage());} $result =& $link->execute($sth); if (DB::isError($result)) {
die($result->getMessage());} I'm no longer getting an error, but nothing actually happens - the db doesn't change! I've included the error code there in case I've done something remarkably stupid. This is the SQL statement pasted straight from the screen, just before it passes to prepare: UPDATE contacts SET contact_firstname='Joe', contact_lastname='Blow', contact_company='', contact_address='1641 Monroe Street', contact_address2 = '', contact_city='Wilson', contact_state='NE', contact_zip='21231-9878', contact_phone = '818-555-1212', contact_phone2='', contact_fax='', contact_mobile = '', contact_voicemail='', contact_pager='', contact_email ='me@domain.com', contact_website='www.site.com', contact_2_firstname='', contact_2_lastname='', contact_3_firstname='', contact_3_lastname = '', contact_password = 'r8ewowr' WHERE contact_id='46617' Thanks for any assistance