public static function setPassword($id, $pass) { execQuery('UPDATE cf_users SET password=:pass WHERE id=:id', array('id' => $id, 'pass' => self::generatePassword(trim($pass), query2var('SELECT salt FROM cf_users WHERE id=:id', array('id' => $id))))); }
public function fullDescr() { if (!is_null($this->fullDescr)) { return $this->fullDescr; } $this->fullDescr = query2var("SELECT full_descr FROM cf_products WHERE id=:id", array('id' => $this->id)); if (!$this->fullDescr && $this->mainID) { $this->fullDescr = query2var("SELECT full_descr FROM cf_products WHERE id=:id", array('id' => $this->mainID)); } return $this->fullDescr; }
public static function countRecords($sql, $params = array()) { $sql = preg_replace('/[\\n\\r]/', '', $sql); $sql = preg_replace('/LIMIT [0-9,]*/i', '', $sql); $sql = preg_replace('/[ ]*ORDER BY .+$/i', '', $sql); return query2var("SELECT COUNT(*) FROM ({$sql}) AS t", $params); }
private function getMinPriceOption() { static $q = null; createStaticQuery($q, "\r\n\t\t\tSELECT cf_products.id, cf_products.price\r\n\t\t\tFROM cf_products\r\n\t\t\tINNER JOIN cf_product_options ON cf_product_options.option_id = cf_products.id\r\n\t\t\tWHERE cf_product_options.product_id=:id\r\n\t\t\t AND cf_products.price > 0\r\n\t\t\tORDER BY cf_products.price ASC\r\n\t\t\tLIMIT 1\r\n\t\t"); $id = query2var($q, array('id' => $this->id())); if ($id && array_key_exists($id, $this->data['options'])) { return $this->data['options'][$id]; } return false; }