Re: PDO, binding within a class

From: Date: Mon, 24 Oct 2005 19:06:35 +0000
Subject: Re: PDO, binding within a class
References: 1  Groups: php.pecl.dev 
Request: Send a blank email to pecl-dev+get-3150@lists.php.net to get a copy of this message
Can you try binding from within a method? IIRC, the engine can be picky about referencing things via $this from the constructor. function __construct( $db ) { $this->db = $db; $this->dobinds(); } function dobinds() { $this->stmt = $this->db->prepare('INSERT STATEMENT'); $this->stmt->bindParam(':var1', $this->stmtvar1); $this->stmt->bindParam(':var2', $this->stmtvar2); } see if that works. --Wez. On 10/24/05, Richard Thomas <lists@cyberlot.net> wrote: > I am tried to define a prepare statement and bind varaibles within the > construct of a class to use everytime a function within the class was > called.. > > No errors reported, it just doesn't run like all the values are empty. > > class testing { > private $stmt = NULL; > private $stmtvar1 = NULL; > private $stmtvar2 = NULL; > private $db = NULL; > > function __construct( $db ) { > $this->db = $db; > $this->stmt = $this->db->prepare('INSERT STATEMENT'); > $this->stmt->bindParam(':var1', $this->stmtvar1); > $this->stmt->bindParam(':var2', $this->stmtvar2); > } > > function noworkie() { > $this->stmtvar1 = 'Something'; > $this->stmtvar2 = 'Something else'; > $this->stmt->execute(); > } > > function workie() { > $this->stmtvar1 = 'Something'; > $this->stmtvar2 = 'Something else'; > $this->stmt->bindParam(':var1', $this->stmtvar1); > $this->stmt->bindParam(':var2', $this->stmtvar2); > $this->stmt->execute(); > } > } > > > No visible errors can be found, errorInfo and errorCode both return no error > > RC1 in both PDO and Mysql > > > -- > Richard Thomas - CEO > Cyberlot Technologies Group Inc. > 507.398.4124 - Voice > > -- > PECL development discussion Mailing List (http://pecl.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >

« previous php.pecl.dev (#3150) next »