多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
### create **在数据表中新增一行数据** **参数** $row: 数组形式,数组的键是数据表中的字段名,键对应的值是需要新增的数据 ~~~ public function create($row) { if (! is_array ( $row )) return FALSE; $row = $this->__prepera_format ( $row ); if (empty ( $row )) return FALSE; foreach ( $row as $key => $value ) { $cols [] = $key; $vals [] = "'" . $this->__val_escape ( $value ) . "'"; } $col = join ( ',', $cols ); $val = join ( ',', $vals ); $sql = "INSERT INTO {$this->tbl_name} ({$col}) VALUES ({$val})"; if (FALSE != $this->_db->query ( $sql )) { // 获取当前新增的ID if ($newinserid = $this->_db->insert_id ()) { return $newinserid; } else { // return array_pop ( $this->find ( $row, "{$this->pk} DESC", $this->pk ) ); } } return FALSE; } ~~~