Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

yii, how to select one column from model

Tags:

makefile

yii

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);


    }
like image 517
Ahmad Khan Avatar asked Oct 17 '13 19:10

Ahmad Khan


2 Answers

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"));
}
like image 172
deacs Avatar answered Nov 10 '22 07:11

deacs


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.

like image 27
Harsh Sanghani Avatar answered Nov 10 '22 09:11

Harsh Sanghani