class xx {
/**
* 添加内容
*
* @param $datas
* @param $isimport 是否为外部接口导入
*/
private function insertContent() {
$this->tabPri = new_addslashes($this->tabPri);
$this->tabData = new_addslashes($this->tabData);
//把数组转换成字符
$this->tabPri = array_map(array($this,'myArray2Str'), $this->tabPri); //调用方式
$this->tabData = array_map(array($this,'myArray2Str'), $this->tabData);
//主表
$tablename = $this->db->table_name = $this->db->db_tablepre.$this->tabName;
$id = $this->db->insert($this->tabPri,true);
//附属表
$this->db->table_name = $this->db->db_tablepre.$this->tabName.'_data';
$this->tabData['id'] = $id;//添加主表关联
$this->db->insert($this->tabData);
//添加统计
$this->db->table_name = $this->db->table_name = $this->db->db_tablepre.'hits';
$hitsid = 'c-'.$this->modelid.'-'.$id;
$this->db->insert(array('hitsid'=>$hitsid,'catid'=>$this->tabPri['catid'],'updatetime'=>SYS_TIME));
return $id;
}
/*
* phpcms的array2string不检测是否数组直接转义
*/
private function myArray2Str($obj){
if (! is_string($obj)){
$obj = array2string($obj);
}
return $obj;
}
}
用法
$this->tabPri = array_map(array($this,'myArray2Str'), $this->tabPri); //调用方式