首頁 >後端開發 >php教程 >mysql int保存数据技巧_PHP教程

mysql int保存数据技巧_PHP教程

WBOY
WBOY原創
2016-07-13 17:05:401029瀏覽


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;
}
}

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/630770.htmlTechArticlepublic function insert($data) { if(isset($data['content'])!empty($data['content'])) { $data_for_query['content'] = trim($data['content']); } else { return false; } if(isset($data['...
陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn