本文整理汇总了PHP中CRUD::query方法的典型用法代码示例。如果您正苦于以下问题:PHP CRUD::query方法的具体用法?PHP CRUD::query怎么用?PHP CRUD::query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRUD
的用法示例。
在下文中一共展示了CRUD::query方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get
public function get($cols = array(), $condition = array(), $row_count = false)
{
$cols = empty($cols) ? array('r.*', 'p.name AS product_name', 'p.uri', 'p.categoryID') : $cols;
$condition = empty($condition) ? $this->set['condition'] : $condition;
$row_count = $row_count ? 'SQL_CALC_FOUND_ROWS' : NULL;
if (is_array($condition)) {
array_walk($condition, create_function('&$i,$k', '$i="$k $i";'));
$condition = ' ' . implode($condition, ' ');
}
$sql = '
SELECT DISTINCT
' . $row_count . '
' . implode(',', $cols) . '
FROM ' . REVIEWS_TABLE . ' AS r
LEFT JOIN ' . PRODUCTS_TABLE . ' AS p ON (r.productID = p.productID)' . $condition;
// fb($sql);
$result = parent::query($sql);
if ($row_count) {
$count_rows = parent::query('SELECT FOUND_ROWS() AS count');
$this->set['amt'] = $this->set['pagination']['total'] = $count_rows[0]['count'];
}
return $result;
}
示例2: getNumPages
public function getNumPages()
{
$r = CRUD::query("SELECT COUNT(*) as cont FROM " . Samus::getTablePrefix() . "pagina_categoria WHERE categoria=" . $this->getId());
$total = $r[0]['cont'];
if (empty($total)) {
$total = 0;
}
return $total;
}
示例3: getPontos
/**
* Pontos representam o numero
* @return int
*/
public function getPontos()
{
$r = CRUD::query("SELECT count(*) as cont FROM " . Samus::getTablePrefix() . "pagina_conteudo_tag WHERE conteudoTag=" . $this->getId());
return $r[0]['cont'];
}