0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

レビューお願いしたら、こんなにダメだった話

0
Posted at

スネークケースとキャメルケースとパスカルケース

preferred_job_types //スネークケース
preferredJobTypes  //キャメルケース
PreferredJobTypes  //パスカルケース

スネークケース・・・DB、変数、関数
キャメルケース・・・インスタンス化したすべての変数、関数
パスカルケース・・・クラス

データベースの値を取得時の効率化

$record = Employmentpattern::where('code', $inputValue)->first();

より

$record = Employmentpattern::where('code', $inputValue)->select('id')->first();

のほうが効率的。
・where()・・・ カラム「name」が「名前1」というデータを取得
・select()・・・カラム「name」だけを取得

他にも
・変数名がイマイチ
・変なところに改行、半角スペース、全角スペース入ってる

全レコードを取得してたが、select()入れることにより、一つのカラムだけ取得できるようになる。

毎回、レビュー依頼時は確認するようにしよ。

0
1
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
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?