时间:2021-07-01 10:21:17 帮助过:17人阅读
public function insert($data)
{
if(isset($data['content'])&&!empty($data['content']))
{
$data_for_query['content'] = trim($data['content']);
}
else
{
return false;
}
if(isset($data['user_id'])&&!empty($data['user_id']))
{
$data_for_query['user_id'] = intval($data['user_id']);
}
else
{
return false;
}
$sql = "INSERT INTO `".$this->table_name."` (".$this->db->implodeToColumn(array_keys($data_for_query)).") VALUES (".$this->db->implodeToValues(array_values($data_for_query)).")";
$this->db->query($sql);
$id = $this->db->lastInsertId();
if(empty($id))
{
return false;
}
else
{
return $id;
}
}
解决办法:还在想,准备用正则表达式。http://www.bkjia.com/PHPjc/322580.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/322580.htmlTechArticlephp保存数据到mysql 打算在dao层进行数据入库前的清理,比如varchar进行trim,int进行intval。 有一天突然想起,php intval的取值范围与mysql的int类...