1

How build this query with YIi query builder

SELECT First_Name,User_ID,
FROM `Users`
WHERE First_name LIKE $_GET['name']
1

2 Answers 2

6

As Örs said everything is in the Yii Guide!

$user = Yii::app()->db->createCommand()
    ->select('First_Name, User_ID')
    ->from('Users')
    ->where('First_name like :name', array(':name'=>$_GET['name']))
    ->queryRow();
Sign up to request clarification or add additional context in comments.

Comments

0
$cr = new CDbCriteria();
$cr->condition = "First_name LIKE '%:name%'";
$cr->params = array(':name'=>$_GET['name']);

$users = Users::model()->findAll($cr);

Another way

1 Comment

Welcome to StackOverflow. Please add some explanation to your code, showing what it does and how it solves the problem posed in the question. This will help others who see your answer in the future

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.