常用代码(3.0)

获取数据
$table = $this -> t_news_inst . ' ni,' . $this -> t_sc_user . ' su';
$fields = 'ni.id,su.pic_url,su.name,ni.create_time,ni.send_state,ni.news_title,ni.news_describe,ni.image_info';
$cond = array(
'ni.id=' => intval($id),
'ni.info_state=' => $this -> info_state,
'^ni.send_user_id=' => 'su.id',
'ni.own_user_id REGEXP ' => '(0|' . $this -> user_id . ')',
'ni.news_title like' => '%' . $condition['keyword'] . '%',
'ni.json_data like' => '%"' . $this -> user_id . '"%',
'na.audit_state IN' => array(1,2),
);
$ret = $this -> pkg_db -> select($table, $fields, $cond);
!is_array($ret) && $ret = array();
return $ret;
 
批量导入数据

// 字段要是数组
$fields = array(
'com_id','form_id','formsetinst_id','work_node_id',
'work_id','assign_id','assign_content','assign_time',
'be_assign_id','create_time',
);
$data = array();
foreach ($be_assign_id_arr as $v) {
$tmp_data = array(
'com_id' => $this -> com_id,
'form_id' => $form_id,
'formsetinst_id' => $formsetinst_id,
'work_node_id' => $work_node_id,
'work_id' => $work_id,
'assign_id' => $assign_id,
'assign_content' => $assign_content,
'assign_time' => $assign_time,
'be_assign_id' => intval($v),
'create_time' => $create_time,
);
$data[] = $tmp_data;
}
$ret = $this -> pkg_db -> batch_insert($this -> t_assign, $fields, $data);

posted on 2017-04-25 00:40  果然朝辉  阅读(155)  评论(0编辑  收藏  举报

导航