Database::fetchObject PHP Method

fetchObject() protected method

protected fetchObject ( $res )
    protected function fetchObject($res)
    {
        $obj = $res->fetch_object();
        if (!$this->ignoreErrors && $this->lastErrNo()) {
            throw new SwarmException('Error in fetchObject: ' . $this->lastErrMsg());
        }
        return $obj;
    }

Usage Example

Example #1
0
 /**
  * Populates the search index with content from all pages
  */
 protected function populateSearchIndex()
 {
     $res = $this->db->select('page', 'MAX(page_id) AS count');
     $s = $this->db->fetchObject($res);
     $count = $s->count;
     $this->output("Rebuilding index fields for {$count} pages...\n");
     $n = 0;
     $fields = array_merge(Revision::selectPageFields(), Revision::selectFields(), Revision::selectTextFields());
     while ($n < $count) {
         if ($n) {
             $this->output($n . "\n");
         }
         $end = $n + self::RTI_CHUNK_SIZE - 1;
         $res = $this->db->select(['page', 'revision', 'text'], $fields, ["page_id BETWEEN {$n} AND {$end}", 'page_latest = rev_id', 'rev_text_id = old_id'], __METHOD__);
         foreach ($res as $s) {
             try {
                 $title = Title::makeTitle($s->page_namespace, $s->page_title);
                 $rev = new Revision($s);
                 $content = $rev->getContent();
                 $u = new SearchUpdate($s->page_id, $title, $content);
                 $u->doUpdate();
             } catch (MWContentSerializationException $ex) {
                 $this->output("Failed to deserialize content of revision {$s->rev_id} of page " . "`" . $title->getPrefixedDBkey() . "`!\n");
             }
         }
         $n += self::RTI_CHUNK_SIZE;
     }
 }
All Usage Examples Of Database::fetchObject