/** * Loads the list from a sql query. * * @param Recipe_Database_Statement_Abstract $result Result set * @param integer $start Rank/Counter start * * @return Bengine_Game_Alliance_List */ public function load($result, $start = 0) { foreach ($result->fetchAll() as $row) { $row["counter"] = $start; $start++; $row["rank"] = $start; $row = $this->formatRow($row); $key = !is_null($this->key) ? (int) $row[$this->key] : $start; $this->list->set($key, $row); } $result->closeCursor(); return $this; }
/** * Builds an unkown cache object. * * @param string $name Object name * @param Recipe_Database_Statement_Abstract $result SQL-Statement * @param string $index Index name of the table * @param string $itype Index type (int or char) * * @return Recipe_Cache */ public function buildObject($name, $result, $index = null, $itype = "int") { $cacheContent = $this->setCacheFileHeader("Cache Object [" . $name . "]"); $data = array(); foreach ($result->fetchAll() as $row) { if (is_null($index)) { array_push($data, $row); } else { if ($itype == "int" || $itype == "integer") { $data[(int) $row[$index]][] = $row; } else { if ($itype == "string" || $itype == "char") { $data[(string) $row[$index]][] = $row; } } } } if (count($data) > 0) { $cacheContent .= "\$data = \"" . $this->compileContent(serialize($data)) . "\";\n"; $cacheContent .= $this->cacheFileClose; try { $this->putCacheContent($this->cacheDir . $name . ".cache.php", $cacheContent); } catch (Recipe_Exception_Generic $e) { $e->printError(); } } return $this; }