Model::select
読み込むカラムを設定します
説明
public self Model::select( string $select )
次のSELECTで取得するカラムを設定します(デフォルトは*)。文字列はそのままSQLに書き込まれるので、ユーザーの入力を入れないでください。ほかのチェーンメソッドと同じく、クエリの実行後にリセットされます。
引数
| 名前 | データ型 | デフォルト | 備考 |
|---|---|---|---|
| $select | string | カラムまたは式(カンマ区切り) |
例
Controller
$model = new Model(false, array(
'table' => 'cms_news',
'id' => 'news_id',
'visible' => 'visible',
));
// Get the `news_id` and `title` columns
$records = $model->select('news_id, title')->find();
// Expressions work too
$records = $model->select('category, count(*) AS n')->group('category')->all();