ユーザ用ツール

サイト用ツール

Writing /var/www/vhosts/w629.ws.domainking.cloud/enjoy-lei.com/lei_wiki/data/cache/0/0e077efe80fbbf26238bdf47cecaa04e.i failed
Unable to save cache file. Hint: disk full; file permissions; safe_mode setting.
Writing /var/www/vhosts/w629.ws.domainking.cloud/enjoy-lei.com/lei_wiki/data/cache/0/0e077efe80fbbf26238bdf47cecaa04e.metadata failed

codeigniterのdbの基本処理
Writing /var/www/vhosts/w629.ws.domainking.cloud/enjoy-lei.com/lei_wiki/data/cache/0/0e077efe80fbbf26238bdf47cecaa04e.i failed
Unable to save cache file. Hint: disk full; file permissions; safe_mode setting.
Writing /var/www/vhosts/w629.ws.domainking.cloud/enjoy-lei.com/lei_wiki/data/cache/0/0e077efe80fbbf26238bdf47cecaa04e.xhtml failed

codeigniterのdbの基本処理

■WHERE $this→db→where('id', $id); $this→db→where('name', $name); WHERE id = 1 AND name = 'yazawa'

$this→db→where('name !=', $name); 等しい以外の場合、スペース必須 $this→db→where($array); 条件を連想配列で:$array = array('name !=' ⇒ $name, ….)

■LIKE $this→db→like('name', 'yazawa'); あるいは $this→db→like('name', 'yazawa', 'both'); WHERE name LIKE '%yazawa%' $this→db→like('name', 'yazawa', 'before'); WHERE name LIKE '%yazawa'

$this→db→like('name', 'yazawa', 'after'); WHERE name LIKE 'yazawa%' ■GROUP BY $this→db→group_by(“name”); GROUP BY name ■HAVING $this→db→having('id = 10'); あるいは $this→db→having('id', 10); HAVING id = 10

■ORDER BY $this→db→order_by(“id”, “desc”); ORDER BY id DESC

■LIMIT $this→db→limit(10); 生成: LIMIT 10

$this→db→limit(10, 50); limit(結果行数, 開始行数) LIMIT 50, 10 LIMIT 開始行数, 結果行数

■その他の条件: or_where(), where_in(), or_where_in(), where_not_in(), or_where_not_in() or_like(), not_like(), or_not_like() or_having() ■削除(DELETE) $this→db→where(条件); $this→db→delete('表名');

■更新(update) 連想配列で更新 $this→db→where(条件); $this→db→update('表名', $array); $array = array('name' ⇒ 'yazawa', …) SET name = 'yazawa'

オブジェクトで更新 $this→db→where(条件); $this→db→update('表名', $object); $object→name = 'yazamwa' SET name = 'yazawa' ■挿入(insert)

連想配列で挿入 $this→db→insert('表名', $array); $array = array('name' ⇒ 'yazawa', …) INSERT INTO 表名(name …) VALUES ('yazawa' …); オブジェクトで挿入 $this→db→insert('表名', $object); $object→name = 'yazamwa'; … INSERT INTO 表名(name …) VALUES ('yazawa' …);

■集計関数(MIN MAX SUM AVG) select_min, select_max, select_sum, select_avg $this→db→select_min('price'); SELECT MIN(price) $this→db→select_min('price', '値段'); SELECT MIN(price) as 値段

codeigniterのdbの基本処理.txt · 最終更新: 2014/11/27 19:19 by luis_lee