Exemple #1
0
 /**
  * @todo cache the result
  * @param boolean $with_limit
  * @return integer
  */
 public function get_count($with_limit = false)
 {
     $limit_stmt = $with_limit ? SqlBuilder::order_by($this->order, $this->order_dir) . SqlBuilder::limit($this->offset, $this->limit) : '';
     $rs = SqlTools::sqlQuery("SELECT count(1)\n                        \nFROM " . SqlBuilder::from($this->get_from_tables()) . SqlBuilder::joins($this->joins, $this->getJoinType()) . SqlBuilder::where($this->where, $this->sql_where) . $limit_stmt);
     if ($rs) {
         return (int) mysql_result($rs, 0);
     } else {
         throw new Exception("Fatal error:" . mysql_error());
     }
 }