php - PDO pass by reference notice? -
this:
$stmt = $dbh->prepare("select thing table color = :color"); $stmt->bindparam(':color', $someclass->getcolor()); $stmt->execute();
yields this:
runtime notice
variables should passed reference
though still executes.
this:
$stmt = $dbh->prepare("select thing table color = :color"); $tempcolor = $someclass->getcolor(); $stmt->bindparam(':color',$tempcolor); $stmt->execute();
runs without complaint.
i don't understand difference?
the second parameter of bindparam variable reference. since function return cannot referenced, fails strictly meet needs of bindparam parameter (php work though , issue warning here).
to better idea, here's , example: code produce same results second example:
$stmt = $dbh->prepare("select thing table color = :color"); $tempcolor = null; // assigned here $stmt->bindparam(':color',$tempcolor); $tempcolor = $someclass->getcolor(); // reassigned here $stmt->execute();
that won't possible function return.
Comments
Post a Comment