Answer the question
In order to leave comments, you need to log in
How to get all table fields except one using DAO Yii?
Good afternoon!
It is necessary to get a row from the table, but not with all the fields, but with the exception of the `users_id` field.
How to implement it correctly using DAO?
Tried with condition but no luck.
$access = Yii::app()->db->createCommand()
->select('*')
->from(self::tableName())
->where('users_id=:id', array(':id'=>$userId))
->condition('users_id NOT IN' . self::tableName())
->queryRow();
Answer the question
In order to leave comments, you need to log in
1) list all required fields in select:
$access = Yii::app()->db->createCommand()
->select('id, name, ...')
->from(self::tableName())
->where('users_id=:id', array(':id'=>$userId))
->queryRow();
$access = Yii::app()->db->createCommand()
->select('*')
->from(self::tableName())
->where('users_id=:id', array(':id'=>$userId))
->queryRow(true);
unset($access['users_id']);
And you definitely need it exactly as you write in the formulation of the question? What does the task look like in real life, i.e. what should be done at the level of business logic, not code?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question