Ejemplo n.º 1
0
 /**
  * Method to obtain the results in an array of objects
  *
  * @param object $class_name[optional]
  * @param object $ctor_args[optional]
  * @return array of objects
  */
 public function result($class_name = 'stdClass', $ctor_args = array())
 {
     $return = array();
     while ($return[] = $this->statement->fetchObject($class_name, $ctor_args)) {
     }
     array_pop($return);
     return $return;
 }
Ejemplo n.º 2
0
 /**
  * Main loop
  *
  * @access public
  */
 function main()
 {
     global $wgContLang;
     fwrite($this->findex, $this->openIndex());
     foreach ($this->namespaces as $namespace) {
         $res = $this->getPageRes($namespace);
         $this->file = false;
         $this->generateLimit($namespace);
         $length = $this->limit[0];
         $i = $smcount = 0;
         $fns = $wgContLang->getFormattedNsText($namespace);
         $this->debug("{$namespace} ({$fns})");
         while ($row = $this->dbr->fetchObject($res)) {
             if ($i++ === 0 || $i === $this->url_limit + 1 || $length + $this->limit[1] + $this->limit[2] > $this->size_limit) {
                 if ($this->file !== false) {
                     $this->write($this->file, $this->closeFile());
                     $this->close($this->file);
                 }
                 $filename = $this->sitemapFilename($namespace, $smcount++);
                 $this->file = $this->open($this->fspath . $filename, 'wb');
                 $this->write($this->file, $this->openFile());
                 fwrite($this->findex, $this->indexEntry($filename));
                 $this->debug("\t{$this->fspath}{$filename}");
                 $length = $this->limit[0];
                 $i = 1;
             }
             $title = Title::makeTitle($row->page_namespace, $row->page_title);
             $date = wfTimestamp(TS_ISO_8601, $row->page_touched);
             $entry = $this->fileEntry($title->getFullURL(), $date, $this->priority($namespace));
             $length += strlen($entry);
             $this->write($this->file, $entry);
             // generate pages for language variants
             if ($wgContLang->hasVariants()) {
                 $variants = $wgContLang->getVariants();
                 foreach ($variants as $vCode) {
                     if ($vCode == $wgContLang->getCode()) {
                         continue;
                     }
                     // we don't want default variant
                     $entry = $this->fileEntry($title->getFullURL('', $vCode), $date, $this->priority($namespace));
                     $length += strlen($entry);
                     $this->write($this->file, $entry);
                 }
             }
         }
         if ($this->file) {
             $this->write($this->file, $this->closeFile());
             $this->close($this->file);
         }
     }
     fwrite($this->findex, $this->closeIndex());
     fclose($this->findex);
 }
Ejemplo n.º 3
0
 /**
  * Result - object
  *
  * Returns the result set as an object
  *
  * @param	string	$class_name
  * @return	object
  */
 protected function _fetch_object($class_name = 'stdClass')
 {
     return $this->result_id->fetchObject($class_name);
 }
Ejemplo n.º 4
0
 /**
  * retrieve an object from the database result set
  *
  * @param object $cursor result set
  * @return object
  */
 private static function fetchObject($cursor)
 {
     return $cursor->fetchObject();
 }
Ejemplo n.º 5
0
 /**
  * Fetches the first row of a result set as an object
  *
  * @param   object $result  The result object.
  * @return  object
  */
 protected function _fetchObject($result)
 {
     $return = $result->fetchObject();
     $result = null;
     return $return;
 }