Home > Backend Development > PHP Tutorial > Tips for saving data in mysql int_PHP tutorial

Tips for saving data in mysql int_PHP tutorial

WBOY
Release: 2016-07-13 17:05:40
Original
1027 people have browsed it


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['...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template