php - Custom PDO Class Fails Quietly -
for reason, custom pdo class fails write database. quietly fails - no error message thrown. similar custom pdo class (readpdo) works wonderfully reading database. sql statement generated works fine when it's queried db through phpmyadmin. i've double-checked user permissions, , seems in order.
i suspect i'm misunderstanding how works. ideas?
// creates write-only pdo, using config settings inc_default.php class writepdo extends pdo{ public function __construct(){ //pull global db settings global $db; global $write_host; global $write_username; global $write_password; try{ parent::__construct("mysql:dbname={$db};host={$write_host}", $write_username, $write_password); } catch (pdoexception $e){ echo 'connection failed: ' . $e->getmessage(); } } } private function updateplayer(){ $conn = new writepdo(); $sql = "update {$this->hvz_db} set hvz_bitten ='{$this->hvz_bitten}', hvz_died ='{$this->hvz_died}', hvz_feedcode ='{$this->hvz_feedcode}', hvz_status ='{$this->hvz_status}', hvz_feeds ='{$this->hvz_feeds}', hvz_lastfed ='{$this->hvz_lastfed}', hvz_ozopt ='{$this->hvz_ozopt}', hvz_parent ='{$this->hvz_parent}' users_id ={$this->id}"; $query = $conn->exec($sql); }
the sql spits out follows:
update hvz_2011_spring set hvz_bitten ='', hvz_died ='', hvz_feedcode ='nomnom', hvz_status ='human', hvz_feeds ='0', hvz_lastfed ='', hvz_ozopt ='0', hvz_parent ='' users_id =1
are sure sql correct?
the exec doesn't send error message.
try doing var_dump($conn->errorinfo()); after $conn->exec($sql);
/emil
Comments
Post a Comment