$sql = "select s.*,COALESCE(SUM(u.use_num), 0) AS use_num from {$this->tbl} as s left join {$this->formula_use_log_tbl} as u on s.id=u.formula_id {$use_limit} where {$where} group by s.id order by use_num desc,s.sort desc,s.id desc limit {$offset},{$page_size}";
$sql = "select s.*,COALESCE(u.use_num, 0) AS use_num from {$this->tbl} as s left join {$this->formula_use_log_tbl} as u on s.id=u.formula_id and u.uid={$uid} where {$where} group by s.id order by use_num desc,s.sort desc,s.id desc limit {$offset},{$page_size}";
return $this->obj->execute($sql, true, true);
$data = $this->obj->execute($sql, true, true);
}
public function getFormulaList($condition, $page_num, $page_size) {
$sql = "select count(*) as count from $this->tbl where {$where}";
$res = $this->obj->execute($sql, true, true);
$num = $res[0]['count'];
return $num;
}
public function getUserFormulaList($condition, $page_num, $page_size) {
$offset = ($page_num - 1) * $page_size;
$uid = 0;
$where = "1=1";
if (!empty($condition)) {
foreach ($condition as $key => $val) {
if ($key == 'uid') $uid = $val;
if ($key == 'name') {
$where .= " and s.{$key} like '%{$val}%'";
} elseif (is_array($val)) {
$val = implode(',', $val);
$where .= " and s.{$key} in ({$val})";
} else {
$where .= " and s.{$key}={$val}";
}
}
}
$sql = "select s.*,COALESCE(u.use_num, 0) AS use_num from {$this->tbl} as s left join {$this->formula_use_log_tbl} as u on s.id=u.formula_id and u.uid={$uid} where {$where} group by s.id order by use_num desc,s.sort desc,s.id desc limit {$offset},{$page_size}";
return $this->obj->execute($sql, true, true);
}
public function getUserFormulaTotal($condition) {
$where = "1=1";
if (!empty($condition)) {
foreach ($condition as $key => $val) {
if ($key == 'name') {
$where .= " and {$key} like '%{$val}%'";
} elseif (is_array($val)) {
$val = implode(',', $val);
$val = implode(',', $val);
$where .= " and {$key} in ({$val})";
$where .= " and {$key} in ({$val})";
} else {
} else {
@ -102,6 +140,67 @@ class mFormula extends mBase {
return $num;
return $num;
}
}
public function getFormulaList($condition, $page_num, $page_size) {