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; }
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; }
/** * 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']; }