bindParam() in Yii changes the parameter type to string when several queries are run

Practice




bindParam() in Yii coerces the parameter's type to a string when there are several queries

try bindValue()

The bindParam() and bindValue() methods are very similar. The only difference is that the first binds the parameter to a reference to a PHP variable, while the second binds it to a value. For parameters that represent a large amount of data, it is preferable from a performance standpoint to use the bindParam() method.

$connection = Yii::app()->db;
$sql2="SELECT ****111" ;
$command = $connection->createCommand($sql2);
$command->bindValue(":limit", $limit, PDO::PARAM_INT);
$rawData = $command->queryRow();


$sql = " SELECT ***22";
$command2 = $connection->createCommand($sql);
$command2->bindValue(":limit", $limit, PDO::PARAM_INT);
$rawData = $command2->queryAll();

Comments

To leave a comment

If you have any suggestion, idea, thanks or comment, feel free to write. We really value feedback and are glad to hear your opinion.
To reply

Lectures and tutorial on "Famworks"

Terms: Famworks