Ahmad Khan
Ahmad Khan

Reputation: 529

yii, how to select one column from model

I have set up model with gii and I have table call make and it has a few columns, there is one that is called make, how can I get all the data from column make back in the controller.

here is my action

  public function actionAutoCompleteMake()
    {


        $makeModel= Make::model()->load(fieldMake);


    }

Upvotes: 5

Views: 25284

Answers (2)

Harsh Sanghani
Harsh Sanghani

Reputation: 1712

You can do this also with some condition :-

$criteria               = new CDbCriteria;
$criteria->select       = "fieldMake";
$criteria->condition    = " fieldName = fieldValue";

$results                = Make::model()->findAll($criteria);

May be It will help you also.

Upvotes: 1

deacs
deacs

Reputation: 4309

If you're new to Yii, you should check out the docs for Yii's Active Record.

public function actionAutoCompleteMake()
{
    $makeModels = Make::model()->findAll(array("select"=>"fieldMake", "order"=>"fieldMake DESC"));
}

Upvotes: 18

Related Questions