Yii Framework Forum: $_GET validation question - Yii Framework Forum

Jump to content

  • (2 Pages)
  • +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

$_GET validation question Rate Topic: -----

#21 User is offline   Y!! 

  • Advanced Member
  • Yii
  • Group: Yii Dev Team
  • Posts: 978
  • Joined: 18-June 09

Posted 11 January 2010 - 12:37 PM

See here. If the first parameter of find() method is no string, you have to bind the params through the criteria object.
0

#22 User is offline   bettor 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 747
  • Joined: 02-February 09

Posted 11 January 2010 - 03:48 PM

View Postbas_vdl, on 11 January 2010 - 12:27 PM, said:

What is wrong:

CDbCommand failed to execute the SQL statement: SQLSTATE[HY093]: Invalid parameter number: no parameters were bound

        echo $_GET['city']; //http://yii.dev/index/test/city/amsterdam.html prints amsterdam on the page
        $criteria = new CDbCriteria;
        $criteria->condition = 'City = :city';
        $city = City::model()->find($criteria, array(':city' => $_GET['city']));




Try this:
$criteria = new CDbCriteria;
$criteria->condition = "City = :city";
$criteria->params = array(':city' => $_GET['city']);
$city = City::model()->find($criteria);

0

Share this topic:


  • (2 Pages)
  • +
  • 1
  • 2
  • 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