protected function acquire($dependency, $fullpath) { $this->products_id = (int) $dependency; // Bypass the query if already in the registry if (false !== isset(usu::$registry->{$this->dependency}[$this->products_id])) { usu::$performance['queries_saved']++; return true; } $placeholders = array(':pid', ':languages_id'); // $values are already type cast $values = array($this->products_id, usu::$languages_id); $this->query = str_replace($placeholders, $values, $this->base_query); $result = usu::query($this->query); $this->query = null; $row = tep_db_fetch_array($result); tep_db_free_result($result); if (false === $row) { return false; } $this->link_text = $this->linkText($row['products_name']); if (false === isset(usu::$registry->{$this->dependency})) { usu::$registry->{$this->dependency} = array(); } usu::$registry->attach($this->dependency, $this->products_id, $this->getProperties()); }
protected function acquire($base_path, $full_path) { $this->dependency_value = $full_path; // Full path perhaps with underscores /** * About placeholders * * The placeholders (items with a colon :) must match those in the query ( $this->base_query in the constructor ) */ $placeholders = array(':manufacturers_id', ':languages_id'); // Do the below values need to be typecast? $values = array((int) $base_path, (int) usu::$languages_id); // xxx These values will replace the placeholders above in $this->base_query $this->query = str_replace($placeholders, $values, $this->base_query); // Replace the placeholders with actual values $result = usu::query($this->query); // Action the query $this->query = null; // Unset the query for future usage $row = tep_db_fetch_array($result); // Return the array of data ( or false if there are no results ) tep_db_free_result($result); // Housekeeping if (false === $row) { return false; // No results for the query so abort } /** * Values obtained from the query, these properties will populate the registry via the method getProperties() * Method $this->linkText() should be used here to convert the text into seo url format e.g. * my great product .. may become .. my-great-product * You may have more than one of these like .. * $this->parentname, $this->catname dependent on how many results you retrieve from your query */ $this->manufacturers_name = $this->linkText($row['manufacturers_name']); // If the registry item doesn't exist as a key then set a blank array if (false === isset(usu::$registry->{self::DEPENDENCY})) { usu::$registry->{self::DEPENDENCY} = array(); } /** * Populate the registry with the properties we have set in this class */ usu::$registry->attach(self::DEPENDENCY, $this->dependency_value, $this->getProperties()); }
public function gc() { $query = str_replace(':cache_name', $this->cachename, $this->gc_query); usu::query($query); $this->retrieved = false; }
private function get_parents(&$categories, $categories_id) { $query = "SELECT parent_id \r\n FROM " . TABLE_CATEGORIES . " \r\n WHERE categories_id='" . (int) $categories_id . "'"; $parent_category_query = usu::query($query); $parent_category = tep_db_fetch_array($parent_category_query); tep_db_free_result($parent_category_query); if ($parent_category['parent_id'] == 0) { return; // We are at the top level so return ending the loop } $categories[count($categories)] = $parent_category['parent_id']; if ($parent_category['parent_id'] != $categories_id) { $this->get_parents($categories, $parent_category['parent_id']); } }