2008年5月14日 星期三

[Debug]CakePHP MODEL::save()有問題

$this->Member->save($this->data['Member']一直無法寫入到Database

找了好久
後來發現原來是某欄位資料前面多了一個空格@@"


foreach($cols as $key => $col_name){
$this->data['Member'][$col_name] = $data['MemberInvite'][$col_name];
}
改成
foreach($cols as $key => $col_name){
$this->data['Member'][$col_name] = trim($data['MemberInvite'][$col_name]);
}
即可
$this->Member->save($this->data['Member']寫入成功!

沒有留言:

wibiya widget