Monday, 15 March 2010

php - Is this an incorrect way to get datetime? -



php - Is this an incorrect way to get datetime? -

i datetime way:

class db_functions extends db_connect{ private $dbconnect = ""; public $dtime; public function __construct() { $this->dbconnect = $this->pdo_connect(); $this->dtime = new datetime(); } public function destruct() { $this->dbconnect = null; } public function exampleinsert() { . . . $result->bindparam(':datecreation',$this->dtime->format("y-m-d h:i:s"),pdo::param_str); } }

then when utilize dtime insert in table, this:

line 1708: $result->bindparam(':datecreation',$this->dtime->format("y-m-d h:i:s"),pdo::param_str);

display error:

<b>strict standards</b>: variables should passed reference in <b>include\db_functions.php</b> on line <b>1708</b><br />

my declaration datetime wrong?

the problem using bindparam() binds variable parameter in query. must variable, not method phone call returns value.

this allows usage like:

$value = 'somevalue'; $result->bindparam(':some_field', $value); $value = 'someothervalue'; $result->execute(); // executes query 'someothervalue' passed parameter.

in case might want utilize bindvalue(). binds value parameter in immutable fashion. either or store formatted datetime different class variable , go on utilize bindparam() new variable.

php datetime

No comments:

Post a Comment