I have the action:
UPDATED Action in Item Controller. Action called from ajaxLink in item/view/#
public function actionAddInterest() {
$itm= Item::model()->find("`ItemId` = :itm", array(':itm' => $_GET['ItemId']));
$connection = yii::app()->db;
$sql1 = "INSERT INTO interest (UserId, ItemId)
VALUES(:usr, :itm)";
$command=$connection->createCommand($sql1);
$command->bindValue(":usr", Yii::app()->user->id);
$command->bindValue(":itm", $itm);
$command->execute();
}
I also tried dumping the variable and through firebug the response for this…returns NULL. So something is not working with the $_GET.
$itm= Item::model()->find("`ItemId` = :itm", array(':itm' => $_GET['ItemId']));
var_dump($itm);
die();
ORIGINAL
public function actionAddInterest() {
$model = new Item;
$connection = yii::app()->db;
$sql1 = "INSERT INTO interest (UserId, ItemId)
VALUES(:usr, :itm)";
$command=$connection->createCommand($sql1);
$command->bindValue(":usr", Yii::app()->user->id);
$command->bindValue(":itm", $model->ItemId);
// $command->bindValue(":itm", $model->ItemId, PDO::PARAM_INT); //also tried
$command->execute();
}
No value is being captured from $model->ItemId though and it returns a NULL for the input. What am I missing here?
Thanks for the help everyone.
To be complete here is the solution..
I have to add
to
This is the ajaxLink that calls the action.