本文整理匯總了PHP中CommonModel::get_list方法的典型用法代碼示例。如果您正苦於以下問題:PHP CommonModel::get_list方法的具體用法?PHP CommonModel::get_list怎麽用?PHP CommonModel::get_list使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類CommonModel
的用法示例。
在下文中一共展示了CommonModel::get_list方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: batch_delete
/**
* @description 批量刪除產品分類
* @author
* @final
* @param array $ids 產品分類id
*/
public function batch_delete()
{
if (!$this->check_power_new('production_category_batch_delete')) {
return;
}
$ids = $this->input->post('ids');
if (empty($ids) or !is_array($ids)) {
message('請選擇要刪除的項目!');
return;
}
// 檢查被關聯試題
$success = $fail = 0;
foreach ($ids as $id) {
$pc_id = intval($id);
$bool = true;
$pc_ids = CommonModel::get_product_category($pc_id);
if (empty($pc_ids)) {
$bool = false;
}
$query = array();
$data = array();
$query['pc_id'] = $pc_id;
$res = CommonModel::get_list($query, 'v_trans_log', 'count(pt_id) as pt_id_count');
$pt_id_count = $res[0]['pt_id_count'];
if ($pt_id_count > 0) {
$bool = false;
}
if (!$bool) {
$fail++;
continue;
}
$num = Fn::db()->delete('rd_product_category', "pc_id={$pc_id}");
admin_log('delete', 'product_category', $pc_id);
if ($num > 0) {
$success += $num;
} else {
$fail++;
}
}
message('批量操作完成,成功刪除:' . $success . ' 個,失敗:' . $fail . ' 個。', 'javascript');
}
示例2: batch_delete
/**
* @description 批量刪除產品信息
* @author
* @final
* @param array $ids 產品id
*/
public function batch_delete()
{
if (!$this->check_power_new('production_batch_delete')) {
return;
}
$ids = $this->input->post('ids');
if (empty($ids) or !is_array($ids)) {
message('請選擇要刪除的項目!');
return;
}
// 檢查被關聯試題
$success = $fail = 0;
foreach ($ids as $id) {
$p_id = intval($id);
$p_ids = CommonModel::get_product_list($p_id);
$bool = true;
if (empty($p_ids)) {
$bool = false;
}
$admin = $this->session->userdata('admin_id');
/*
$managers = explode(',',$p_ids['p_managers']);
if(!in_array($admin, $managers)&&!$this->check_power_new('production_del'))
{
$bool = false;
}
*/
$query = array();
$query['p_id'] = $p_id;
$res = CommonModel::get_list($query, 'v_trans_log_count', 'pt_id_count');
$pt_id_count = $res[0]['pt_id_count'];
if ($pt_id_count > 0) {
$bool = false;
}
if (!$bool) {
$fail++;
continue;
}
$num = Fn::db()->delete('rd_product', "p_id={$p_id}");
admin_log('delete', 'product', $p_id);
if ($num > 0) {
$success += $num;
} else {
$fail++;
}
}
$back_url = 'admin/prodution/index/';
message('批量操作完成,成功刪除:' . $success . ' 個,失敗:' . $fail . ' 個。', 'javascript');
}
示例3: info_check
/**
* 學生報名信息核對
*/
public function info_check()
{
if ($this->input->post('grade_id')) {
$this->load->library('PHPExcel');
$this->load->library('PHPExcel/IOFactory');
$grade_id = intval($this->input->post('grade_id'));
$school_id = intval($this->input->post('school_id'));
if (!$grade_id) {
message('請選擇年級');
}
if (!$school_id) {
message('請選擇學校');
}
$file = $_FILES['infos']['name'];
$desc = '../../cache/excel/' . $file;
$tmp_name = $_FILES['infos']['tmp_name'];
$extend = strrchr($file, '.');
if (!in_array($extend, array('.xlsx', '.xls'))) {
message('文件類型不合法');
}
if (!move_uploaded_file($tmp_name, $desc)) {
message('文件移動失敗,請聯係管理員');
}
$reader = new PHPExcel_Reader_Excel2007();
$reader_type = $extend == '.xlsx' ? 'Excel2007' : 'Excel5';
$obj = new IOFactory();
$objreader = $obj::createReader($reader_type)->load($desc);
$sheet = $objreader->getSheet(0);
$allRow = $sheet->getHighestRow();
$file2 = $file . '信息核對反饋表';
$objexcel = new PHPExcel();
$objexcel->setActiveSheetIndex(0)->setCellValue('A1', '姓名');
$objexcel->setActiveSheetIndex(0)->setCellValue('B1', '學號');
$objexcel->setActiveSheetIndex(0)->setCellValue('C1', '年級');
$objexcel->setActiveSheetIndex(0)->setCellValue('D1', '準考證號');
$objexcel->setActiveSheetIndex(0)->setCellValue('E1', '報名');
$objexcel->getActiveSheet()->setTitle($file2);
$objwriter = IOFactory::createWriter($objexcel, $reader_type);
for ($i = 2; $i <= $allRow; $i++) {
$arr = array();
$student_name = $objreader->getActiveSheet()->getCell('A' . $i)->getValue();
$student_number = $objreader->getActiveSheet()->getCell('B' . $i)->getValue();
$student_grade = $objreader->getActiveSheet()->getCell('C' . $i)->getValue();
$space = " ";
$student_name = str_ireplace($space, "", $student_name);
$count = 0;
$objexcel->setActiveSheetIndex(0)->setCellValue('A' . $i, $student_name);
$objexcel->setActiveSheetIndex(0)->setCellValue('B' . $i, $student_number);
$objexcel->setActiveSheetIndex(0)->setCellValue('C' . $i, $student_grade);
$student_search = array('school_id' => $school_id, 'grade_id' => $grade_id, 'keyword' => "CONCAT(last_name,first_name) LIKE '%" . trim($student_name) . "%'");
$student_list = CommonModel::get_list($student_search, 'rd_student', '*');
$number = count($student_list);
if ($number) {
if ($number > 1) {
//2代表錯誤,一個學校一個年紀有多個重名學生情況
$objexcel->setActiveSheetIndex(0)->setCellValue('D' . $i, '報名出錯了(重名情況)');
$objexcel->setActiveSheetIndex(0)->setCellValue('E' . $i, 2);
} else {
$student_info = array_shift($student_list);
$idcard = $student_info['idcard'];
$objexcel->setActiveSheetIndex(0)->setCellValue('D' . $i, $student_info['exam_ticket']);
$objexcel->setActiveSheetIndex(0)->setCellValue('E' . $i, 1);
}
} else {
$objexcel->setActiveSheetIndex(0)->setCellValue('D' . $i, '未報名');
$objexcel->setActiveSheetIndex(0)->setCellValue('E' . $i, 0);
}
}
$objwriter->save($desc);
$data = array('url' => $desc, 'act' => 'update', 'name' => $file);
} else {
$grades = C('grades');
$data = array('act' => 'add', 'grades' => $grades);
}
$this->load->view('/student/info_check', $data);
}
示例4: transactionp
/**
* @按產品查詢交易數據信息
* @param int $p_id 產品id
*/
public function transactionp($p_id)
{
if (!$this->check_power('statistics_manage')) {
return;
}
$p_id = intval($p_id);
$student = CommonModel::get_product_list($p_id);
if (empty($student)) {
message('信息不存在');
return;
}
$admin = $this->session->userdata('admin_id');
$managers = explode(',', $student['p_managers']);
if (!in_array($admin, $managers) && !$this->is_super_user()) {
message('沒有管理權限');
return;
}
/*
* 基本信息
*/
$p_id = intval($p_id);
$student = CommonModel::get_product_list($p_id);
if (empty($student)) {
message('信息不存在');
return;
}
$data = array();
$data['p_id'] = $p_id;
$data['p_name'] = $student[p_name];
$query = array();
$query['p_id'] = $p_id;
$query['pt_type'] = 0;
/* 搜索條件 */
if (isset($_GET['begin_time']) && !empty($_GET['begin_time'])) {
$query['pt_u_time >='] = strtotime($_GET['begin_time'] . '00:00:59');
$search['begin_time'] = $_GET['begin_time'];
}
if (isset($_GET['end_time']) && !empty($_GET['end_time'])) {
$query['pt_u_time <='] = strtotime($_GET['end_time'] . '23:59:59');
$search['end_time'] = $_GET['end_time'];
}
// 公共數據
$res = CommonModel::get_list($query, 'v_trans_log', 'count(pt_id) as pt_id_count,sum(pt_money)*(-1) as pt_money_count');
$data['p_id_count'] = $res[0]['pt_id_count'];
$data['p_money_count'] = !empty($res[0]['pt_money_count']) ? $res[0]['pt_money_count'] : 0;
$total = $res[0]['pt_id_count'];
/*
* 分頁讀取數據列表,並處理相關數據
*/
$size = 10;
$page = isset($_GET['page']) && intval($_GET['page']) > 1 ? intval($_GET['page']) : 1;
$offset = ($page - 1) * $size;
$list = array();
if ($total) {
$res = CommonModel::get_list($query, 'v_trans_log', 'pt_id,p_name,pc_name,end_time,start_time,a_name,pt_money', $page, $size);
foreach ($res as $row) {
$row['start_time'] = $row['start_time'] > 0 ? date('Y-m-d H:i:s', $row['start_time']) : date('Y-m-d H:i:s', time());
$row['end_time'] = $row['end_time'] > 0 ? date('Y-m-d H:i:s', $row['end_time']) : date('Y-m-d H:i:s', time());
$row['p_name'] = !empty($row['p_name']) ? $row['p_name'] : '充值';
$row['pt_money'] = !empty($row['pt_money']) ? $row['pt_money'] * -1 : '0';
$row['pc_name'] = !empty($row['pc_name']) ? $row['pc_name'] : '充值';
$list[] = $row;
}
}
$data['list'] = $list;
// 分頁
$purl = site_url('admin/account/transactionp/' . $p_id);
$data['pagination'] = multipage($total, $size, $page, $purl);
$data['search'] = $search;
// 模版
$this->load->view('account/transactionp', $data);
}