public function findAll($opciones = array(), $pagina = 1, $items_by_page = 20)
 {
     $db = CoreDb::getInstance();
     $where = "";
     // select all active users
     if (sizeof($opciones) > 0) {
         $w = CoreRoute::getWhere($opciones);
         if (sizeof($w) > 0) {
             $where = " WHERE " . implode(" AND ", $w);
         }
     }
     $result = $db->query("SELECT count(id) as total FROM " . $this->dbTable . $where, 1);
     $total = $result[0]["total"];
     $result = $db->query("SELECT * FROM " . $this->dbTable . $where . " LIMIT " . ($pagina - 1) * $items_by_page . "," . $items_by_page);
     return array("records" => $result, "total" => $total);
 }
 public static function getDbInstance()
 {
     return CoreDb::getInstance();
 }