Yii Framework Forum: query with parameters - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

query with parameters Rate Topic: -----

#1 User is offline   dimis283 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 277
  • Joined: 24-January 09

Posted 16 February 2010 - 09:42 AM

I am trying to run this code but it does not work, what is wrong?
 $sql="select cat_id from cats where cat_link=':links'";
 $command=Yii::app()->db->createCommand($sql);
 $dataReader=$command->query(array (':links'=>$_GET['cat']));

Posted Image
0

#2 User is offline   dimis283 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 277
  • Joined: 24-January 09

Posted 16 February 2010 - 09:45 AM

I wrote this and it worked, is this right?.
$sql="select cat_id from cats ";
$command=Yii::app()->db->createCommand($sql);
$dataReader=$command->query(array ('cat_link'=>$_GET['cat']));

[edit]The code that worked were that
$sql="select cat_id from cats where cat_link=:link ";
$command=Yii::app()->db->createCommand($sql);
 $dataReader=$command->query(array (':link'=>$_GET['cat']));

Posted Image
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users