示例#1
0
function smarty_function_getall($params, &$smarty)
{
    if (!isset($params['from'])) {
        echo 'No table name!';
        return false;
    }
    if (!isset($params['_name'])) {
        echo 'No record variable name!';
        return false;
    }
    global $php;
    $select = new SelectDB($php->db);
    $select->call_by = 'func';
    if (!isset($params['order'])) {
        $params['order'] = 'id desc';
    }
    $select->put($params);
    if (isset($params['page'])) {
        $select->paging();
        $pager = $select->pager;
        $smarty->assign("pager", array('total' => $pager->total, 'render' => $pager->render()));
    }
    $records = $select->getall();
    $smarty->_tpl_vars[$params['_name']] = $records;
}
示例#2
0
 function fetch_select($dname, $params)
 {
     $select = new SelectDB($this->swoole->db);
     $select->from($dname);
     $select->put($params);
     return $select->getall();
 }
示例#3
0
function smarty_block_select($params, $body, &$smarty)
{
    if (is_null($body)) {
        return;
    }
    global $php;
    $select = new SelectDB($php->db);
    $select->put($params);
    return SwooleTemplate::parse_loop($select->getall(), $body);
}
 function proc_records($tag, $tag_head)
 {
     $param = self::parse_param($tag);
     $select = new SelectDB($this->db);
     $select->put($param);
     $body = $this->get_body('records');
     $list = $select->getall();
     $content = '';
     foreach ($list as $record) {
         $content .= $this->parse_record_body($body, $record);
     }
     $this->out_content .= $content;
     $this->clear('records');
 }
示例#5
0
 /**
  * 获取一个数据列表,功能类似于gets,此方法仅用于SiaoCMS,不作为同样类库的方法
  * @param $params
  * @param $get
  * @return array
  */
 function getList(&$params, $get = 'data')
 {
     $selectdb = new SelectDB($this->db);
     $selectdb->from($this->table);
     $selectdb->select($this->select);
     $selectdb->limit(isset($params['row']) ? $params['row'] : 10);
     unset($params['row']);
     $selectdb->order(isset($params['order']) ? $params['order'] : $this->primary . ' desc');
     unset($params['order']);
     if (isset($params['typeid'])) {
         $selectdb->where($this->foreignkey . '=' . $params['typeid']);
         unset($params['typeid']);
     }
     $selectdb->put($params);
     if (array_key_exists('page', $params)) {
         $selectdb->paging();
         global $php;
         $php->env['page'] = $params['page'];
         $php->env['start'] = 10 * intval($params['page'] / 10);
         if ($selectdb->pages > 10 and $params['page'] < $php->env['start']) {
             $php->env['more'] = 1;
         }
         $php->env['end'] = $selectdb->pages - $php->env['start'];
         $php->env['pages'] = $selectdb->pages;
         $php->env['pagesize'] = $selectdb->page_size;
         $php->env['num'] = $selectdb->num;
     }
     if ($get === 'data') {
         return $selectdb->getall();
     } elseif ($get === 'sql') {
         return $selectdb->getsql();
     }
 }