LoginSignup
2
2

More than 5 years have passed since last update.

電話番号や名前を扱う時virtualFieldsが使えそう

Posted at

080-0000-0000 をDBのtel1,tel2,tel3フィールドに分けて登録したり
田中 太郎 をDBname1,name2フィールドに分けて登録してる時は

public $virtualFields = array(
    'full_name' => 'CONCAT(User.name1,User.name2)',
    'full_tel' => 'CONCAT(User.tel1,User.tel2,User.tel3)',
);

がよさそう。
ユーザー情報一覧表ページにて、

$this->Paginator->sort('full_name', '名前順に並び替える')

を使ってユーザーを名前順や電話番号順に並び替える時に使いました。
$this->Paginator->sort('name1', '名前順に並び替える') だと、下の名前まで入れて並び替えできないので。

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2