【发布时间】:2014-03-13 14:50:26
【问题描述】:
我有一些代码:
function save_article() {
$data = array(
'post_id' => NULL,
'post_author' => 1,
'post_cat' => $this->var->post('category'),
'post_title' => $this->var->post('title'),
'post_content' => $this->var->post('content'),
'post_date' => null,
'post_thumb' => $this->var->post('thumbnail'),
'post_type' => 'tutorial',
'post_hits' => 0
);
$this->db->insert($data, "tbl_posts");
}
这个函数是$this->db对象类的一部分
public function insert($data, $tbl) {
$query = "insert into ".$tbl." set";
foreach ($data as $field => $value) {
$query .= $field."=". mysql_real_escape_string($value) .",";
}
$query = rtrim($query, ",");
$result = mysql_query($query);
return $result;
}
但由于某种原因,数据没有保存在数据库中。
【问题讨论】:
-
这个问题似乎跑题了,因为 StackOverflow 不是众包调试工具。