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

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -