note 85162 modified in pdostatement.bindparam by felipe

From: Date: Tue, 19 Aug 2008 01:40:45 +0000
Subject: note 85162 modified in pdostatement.bindparam by felipe
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-143615@lists.php.net to get a copy of this message
@charlie smith That behavior is expected since you are binding named parameters outside of your loop. to achieve your desired results: <?php $query = 'INSERT INTO pdotest SET storeid = :storeid, testid = :testid'; $statement = $con->prepare($query); foreach ($result as $row) { $statement->bindParam(':storeid',$row['storeid']); $statement->bindParam(':testid',$row['testid']); $statement->execute(); } ?> --was-- @charlie smith That behavior is expected since you are binding named parameters outside of your loop. to achieve your desired results: $query = 'INSERT INTO pdotest SET storeid = :storeid, testid = :testid'; $statement = $con->prepare($query); foreach ($result as $row) { $statement->bindParam(':storeid',$row['storeid']); $statement->bindParam(':testid',$row['testid']); $statement->execute(); } http://php.net/manual/en/pdostatement.bindparam.php

« previous php.notes (#143615) next »