Example #1
0
 public function fetch($limit = 1, $offset = 0, $pid = NULL, $wherePid = FALSE)
 {
     $table = new \apf\db\mysql5\Table($this->_table);
     $select = new \apf\db\mysql5\Select($table);
     $fields = array("id", "estado", "uri", "categoria", "pais", "provincia");
     $select->fields($fields);
     $where = array(array("field" => "estado", "operator" => "!=", "value" => "-1"), array("operator" => "AND"), array("field" => "estado", "operator" => "!=", "value" => "1"));
     if ($wherePid) {
         $where[] = array("operator" => "AND");
         $where[] = array("field" => "pid", "value" => $pid);
     }
     if ($offset > 0) {
         $select->offset($offset);
     }
     $select->where($where);
     $select->limit(array($limit));
     $uris = $select->execute($smartFetch = FALSE);
     $returnQueue = array();
     $class = __CLASS__;
     foreach ($uris as $uri) {
         $queue = new $class();
         $queue->setId($uri["id"]);
         $queue->setEstado('-1');
         if ($pid) {
             $queue->setPid($pid);
         }
         $queue->update();
         $queue->setUri($uri["uri"]);
         $queue->setCategoria($uri["categoria"]);
         $queue->setPais($uri["pais"]);
         $queue->setProvincia($uri["provincia"]);
         $returnQueue[] = $queue;
     }
     return $returnQueue;
 }