public function get_list($params = array(), $page = 1, $rows = 10) { if (!empty($params) && is_array($params)) { foreach ($params as $pk => $pv) { $tmp[] = $pk . '=' . $pv; } } $query_str = !empty($tmp) ? implode(" and ", $tmp) : ''; $sql = "select count(1) as num from op_api "; if (!empty($query_str)) { $sql .= "where " . $query_str; } $db = Yii::$app->db; $total = $db->createCommand($sql)->queryOne(); $sql = "select * from op_api "; if (!empty($query_str)) { $sql .= "where " . $query_str; } $sql .= " order by created_at desc "; if ($page >= 1) { $page = ($page - 1) * $rows; $sql .= " limit {$page}, {$rows}"; } $re = $db->createCommand($sql)->queryAll(); common\multi::get_api($re); if (!$re) { return false; } return array('total' => $total['num'], 'rows' => $re); }
public function get_list($params = array(), $page = 1, $rows = 10) { if (!empty($params) && is_array($params)) { foreach ($params as $pk => $pv) { $tmp[] = $pk . '=' . $pv; } } $query_str = !empty($tmp) ? implode(" and ", $tmp) : ''; $sql = "select count(1) as num from op_key"; $db = Yii::$app->db; if (!empty($query_str)) { $sql .= "where " . $query_str; } $total = $db->createCommand($sql)->queryOne(); $sql = "select * from op_key "; if (!empty($query_str)) { $sql .= "where " . $query_str; } $sql .= " order by created_at desc "; if ($page >= 1) { $page = ($page - 1) * $rows; $sql .= " limit {$page}, {$rows}"; } $re = $db->createCommand($sql)->queryAll(); $apply_id = common\Assist::get_fields($re, 'apply_id'); $apply_tmp = array(); if (!empty($apply_id)) { $apply_info = (new Api_apply())->get_info_fieldid($apply_id); if (!empty($apply_info)) { foreach ($apply_info as $ak => $av) { $apply_tmp[$av['id']] = $av; } } } foreach ($re as $rk => $rv) { $re[$rk]['uid'] = isset($apply_tmp[$rv['apply_id']]['uid']) ? $apply_tmp[$rv['apply_id']]['uid'] : ''; $re[$rk]['aid'] = isset($apply_tmp[$rv['apply_id']]['aid']) ? $apply_tmp[$rv['apply_id']]['aid'] : ''; $re[$rk]['rate'] = isset($apply_tmp[$rv['apply_id']]['rate']) ? $apply_tmp[$rv['apply_id']]['rate'] : ''; $re[$rk]['is_agree'] = isset($apply_tmp[$rv['apply_id']]['is_agree']) ? $apply_tmp[$rv['apply_id']]['is_agree'] : ''; } common\multi::get_multi($re); if (!$re) { return false; } return array('total' => $total['num'], 'rows' => $re); }
public function actionItem() { $id = isset($_GET['id']) ? $_GET['id'] : ''; $page = isset($_POST['page']) ? $_POST['page'] : 1; $rows = isset($_POST['rows']) ? $_POST['rows'] : 10; if (empty($id)) { echo '参数有误'; exit; } $params = ['aid' => $id, 'is_agree' => 1]; $apply_obj = new \app\models\Api_apply(); $apply_info = $apply_obj->get_list($params, $page, $rows); $apply_info_rows = $this->process_allly_info($apply_info['rows']); \app\models\common\multi::get_multi($apply_info_rows); // 根据接口id查询申请记录 $re['total'] = $apply_info['total']; $re['rows'] = $apply_info_rows; echo json_encode($re); }