[[Kawahara Dental Clinic]] **データ挿入時にダブルクウォートがおかしくなっている? [#x26e159b] -データベース挿入前にシングルクウォートを置換すればよい --いちいち挿入ごとに置換するのは手間がかかる --モデルごとにbeforeSaveを定義するのも手間がかかる --そこでmodelの親クラスのbeforeSaveを書き換える -~/cake/app_model.phpを以下のように拡張 class AppModel extends Model{ function beforeSave(){ $this->data = $this->stripDoubleQoute($this->data); } function stripDoubleQoute($data){ foreach($data as $key => $content){ if( is_array($content) ) $data[$key] = $this->stripDoubleQoute($content); else $data[$key] = str_replace("before","after",$data[$key]); } return $data; } } -連想配列の再帰処理で手間取った --こんなのもあるみたい。まだ試してない。 --http://us3.php.net/manual/ja/function.array-walk-recursive.php **なおらないのでbeforeSaveの実行されるタイミングを見てみる [#r6e25635] -たぶんサニタイズ前に行われている **DB挿入前にすでにデータがおかしくなっている? [#c49a6acf] -incident_controller.phpのsaveの前にデータを出力するとデータ挿入前にすでにおかしくなっているみたい?