/** * Only private function for recursive get the items and subitems */ private function _getRecursive($pid = NULL) { $nodes = array(); $states = $this->getStates(); if (isset($states['tre_active']) and isset($states['pid']) and count($states) <= 2) { if (isset($this->_pidArray[(int) $states['pid']])) { return $this->_pidArray[(int) $states['pid']]; } } if ($pid) { $states['pid'] = $pid; if (isset($states['tre_id'])) { unset($states['tre_id']); } } $q = $this->getListQuery($states); if (isset($states['showSQL'])) { print $q->toString() . "\n" . print_h($q->getValues(), true); } foreach ($this->queryAll($q->toString(), $q->getValues()) as $key) { $nodes[] = new struct_coremenus_tree($key); } for ($i = 0; $i < count($nodes); $i++) { if (!$nodes[$i]->tre_islast and $nodes[$i]->tre_pid != $nodes[$i]->tre_id) { $nodes[$i]->child = $this->_getRecursive($nodes[$i]->tre_id); } } if (isset($states['tre_active']) and isset($states['pid']) and count($states) <= 2) { $this->_pidArray[(int) $states['pid']] = $nodes; } return $nodes; }
/** * Executes the SQL string * @param string $sql * @return integer - number of updated\inserted rows */ public function execSQLi($sql) { $return = $this->exec($sql); if ((int) $this->getPDO()->errorCode()) { echo print_h($this->getPDO()->errorInfo(), true); } return $return; }
/** * Gets the fields * * @param Boolean $joinMeasurement - need to join measurement table? * @return array of struct_corecatalog_cat_val_names */ function getItems($joinMeasurement = false, $ct_showing = false, $node_id = 0, $pid_types = 0) { $fk['measurement'] = $joinMeasurement; $fk['ct_showing'] = $ct_showing; $node_id = $node_id ? $node_id : $this->getState('node_id') ? $this->getState('node_id') : $this->getState('vl_tre_id') ? $this->getState('vl_tre_id') : ($this->getState('tre_id') ? $this->getState('tre_id') : 0); $pid_types = $pid_types ? $pid_types : $this->getState('pid_types', 0) ? $this->getState('pid_types') : 0; $result = array(); if (!$this->getState('without_parents') and $node_id > 0 and $pid_types > 0) { $modelTree = rad_instances::get('model_coremenus_tree'); $currTree = $modelTree->getItem($node_id); $treeToRoot = $modelTree->getCategoryPath($currTree, $pid_types, 0); $ids = array(); foreach ($treeToRoot as $ttr) { if ($ttr->tre_id == $pid_types) { continue; } else { $ids[] = (int) $ttr->tre_id; } } $ids[] = $node_id; $this->setState('vl_tre_id', $ids); } $q = $this->getListQuery($this->getStates(), $fk); if ($this->getState('showSQL')) { print_h($q->getValues()); die($q->toString()); } if ($this->getState('return.array')) { return $this->queryAll($q->toString(), $q->getValues()); } foreach ($this->queryAll($q->toString(), $q->getValues()) as $key) { $result[] = new struct_corecatalog_cat_val_names($key); if ($joinMeasurement) { $result[count($result) - 1]->ms_value = new struct_corecatalog_measurement($key); } } //Join the rad_cat_val_values if ((int) $this->getState('cat_id')) { $values = $this->getValValues((int) $this->getState('cat_id')); if (count($values)) { foreach ($values as $id) { for ($i = 0; $i < count($result); $i++) { if ($result[$i]->vl_id == $id->vv_name_id) { $result[$i]->vv_values[] = $id; } } //for $i } //foreach } } //if cat_id return $result; }
/** * Gets the users items by params and states * @return array of struct_core_users */ function getItems($limit = null) { $q = $this->_getListQuery($this->getStates()); $result = array(); $limit = $limit ? $limit : $this->getState('limit', $limit); $limit = $limit ? ' LIMIT ' . $limit : ''; if ($this->getState('showSQL')) { die($q->toString() . $limit . print_h($q->getValues(), true)); } foreach ($this->queryAll($q->toString() . $limit, $q->getValues()) as $key) { $result[] = new struct_core_users($key); if ($this->getState('join.group')) { $result[count($result) - 1]->group = new struct_coremenus_tree($key); } } return $result; }
/** * Get all orders of the partner * @throws rad_exception * @return multitype:struct_coresession_referals_orders |NULL */ function getPartnerOrders() { if (!$this->getState('rrf_user_id')) { throw new rad_exception('Not enough actual param "rrf_user_id" in referals model!', __LINE__); } if (!$this->getState('date.from')) { print_h($this->getStates()); throw new rad_exception('Not enough actual param "date.from" in referals model!!', __LINE__); } if (!$this->getState('date.to')) { throw new rad_exception('Not enough actual param "date.to" in referals model!', __LINE__); } $q = new rad_query(); $q->from(RAD . 'referals_orders a')->select('a.*, o.order_status, o.order_dt, o.order_currency')->join('INNER', RAD . 'orders o ON o.order_id=a.rro_order_id')->join('INNER', RAD . 'referals r ON r.rrf_id=a.rro_referals_id')->where('r.rrf_user_id=:rrf_user_id')->value(array('rrf_user_id' => (int) $this->getState('rrf_user_id')))->where('o.order_dt BETWEEN :date_from AND :date_to')->value(array('date_from' => date($this->config('date.format'), $this->getState('date.from')), 'date_to' => date($this->config('date.format'), $this->getState('date.to') + 86400))); $res = $this->queryAll($q->toString(), $q->getValues()); if ($res) { $result = array(); foreach ($res as $id) { $result[] = new struct_coresession_referals_orders($id); } return $result; } return NULL; }
print_n(" [\"PREFERED_TLD\"] => string(n) # The Toolbar top level domain *you* prefer."); print_n(" [\"GTB_SUGESSTED_TLD\"] => string(n) # The Toolbar top level domain Google suggests to you."); print_n(" [\"GTB_QUERY_STRINGS\"] => string(n) # Array of possible path combination, based on different hashes (max. Arraysize: 4)."); print_n(" [\"GTB_SERVER\"] => array(3) { # Array containing the Toolbar server adress parts."); print_n(" [\"host\"] => array(2) # Array containing valid toolbar host names."); print_n(" [\"tld\"] => array(138) # Array containing valid toolbar top level domains."); print_n(" [\"path\"] => string(4) \"/tbr\" } # The toolbar request path."); print_n("}"); print_cbe(); print_n("For the initialized test URL, the full object looks as follows."); print_cbb("\$_url"); # BEGIN code block var_dump($_url); print_cbe(); # END code block print_h("== GET THE PAGERANK =="); print_n("As we saw, the object holds all data we need to request the PageRank."); print_n("Now, it is just a question of how you work with the data."); print_n(); print_n("Need a single hash key? Try one of:"); print_cbb(); # BEGIN code block print_n("\t`\$_url->GPR_ieHash()`\n\t`\$_url->GPR_jenkinsHash()`\n\t`\$_url->GPR_jenkinsHash2()` or \n\t`\$_url->GPR_awesomeHash()` :"); print_n("Output:"); print_n("\t" . $_url->GPR_ieHash() . "\n\t" . $_url->GPR_jenkinsHash() . "\n\t" . $_url->GPR_jenkinsHash2() . "\n\t" . $_url->GPR_awesomeHash()); print_cbe(); # END code block print_n(); print_n("The same could be achieved using the `getHash(key)` method providing one of the key names"); print_n("'awesome', 'jenkins', 'jenkins2', or 'ie'."); print_cbb("\$_url->getHash('awesome')");
public static function print_h() { print_h($_SESSION); }
/** * Execute an SQL statement and return the number of affected rows * Just analog of PDO functions * @param string $query * @param boolean $escapeCheck - Need to escape for deletes,updates and inserts? * @return integer numrows */ public static function exec($query = '', $escapeCheck = false) { self::check_connection(); self::$sql_history[] = $query; if ($escapeCheck) { return self::$dbc->exec($query); } elseif (rad_config::getParam('cache.power') and !1) { // die('cache.power file: '.__FILE__.' and line: '.__LINE__); $sql = trim($query); $tmp = explode(' ', $sql); //TODO Add more sql operators! switch (strtolower($tmp[0])) { case 'insert': case 'select': case 'delete': $res = self::$dbc->exec($query); if ($res) { rad_cacheutils::incTableVer(trim($tmp[2])); } break; case 'truncate': case 'update': $res = self::$dbc->exec($query); if ($res) { rad_cacheutils::incTableVer(trim($tmp[1])); } break; case 'show': case 'set': $res = self::$dbc->exec($query); break; default: print_h($tmp); throw new rad_exception('can\'t parse SQL when power caching is on!', __LINE__); break; } //switch return $res; } else { return self::$dbc->exec($query); } }
/** * Return the products list * @param boolean $withvals * @param integer $ct_showing * @return struct_corecatalog_catalog array */ function getProductsList($withvals = false, $ct_showing = 0) { $tre_id = (int) $this->getState('cit_tre_id', $this->getState('tre_id')); if ($tre_id or $this->getState('where_condition') or $this->getState('cat_id') or $this->getState('tag_id')) { $result = array(); $q = new rad_query(); $q->select('c.*,cr.cur_name AS currency_name, cr.cur_cost AS currency_cost, cr.cur_ind AS currency_indicate, ct.tre_name AS cat_ct_name, ct.*, i.img_filename AS img_filename'); if ($this->getState('tag_id')) { $q->from(RAD . 'catalog c'); } else { $q->from(RAD . 'cat_in_tree'); $q->join('LEFT', RAD . 'catalog c ON cit_cat_id=cat_id'); } $q->join('LEFT', RAD . 'currency cr ON cat_currency_id=cr.cur_id'); $q->join('LEFT', RAD . 'tree ct ON cat_ct_id=tre_id'); $q->join('LEFT', RAD . 'cat_images i ON img_cat_id=cat_id AND img_main=1'); $orderj = ''; if ($this->getState('special_offer')) { $q->join('INNER', RAD . 'cat_special cs ON cs.cs_catid=c.cat_id AND cs.cs_type=:cs_type')->value(array('cs_type' => (int) $this->getState('special_offer'))); $orderj = $this->getState('order by') ? ' ' . $this->getState('order by') : ' cs.cs_order,'; } if ($this->getState('where_condition')) { $q->where($this->getState('where_condition')); } elseif (!$this->getState('tag_id')) { $q->where('cit_tre_id=:cit_tre_id')->value(array('cit_tre_id' => $tre_id)); } if ($this->getState('active', 2) == 1 or $this->getState('active', 2) == 0) { $q->where('cat_active=:cat_active')->value(array('cat_active' => $this->getState('active'))); } if ($this->getState('lang')) { $q->where('cat_lngid=:cat_lngid')->value(array('cat_lngid' => $this->getState('lang'))); } if ($this->getState('cat_id') and is_array($this->getState('cat_id'))) { $q->where('cat_id IN (:cat_id_in)')->value(array('cat_id_in' => implode(',', $this->getState('cat_id')))); } if ($this->getState('tag_id')) { $q->join('INNER', RAD . 'tags_in_cat tic ON tic.tic_cat_id = c.cat_id AND tic.tic_tag_id=:tic_tag_id'); $q->value(array('tic_tag_id' => $this->getState('tag_id'))); } if ($this->getState('group by')) { $q->group($this->getState('group by')); } else { $q->group('cat_id'); } if ($this->getState('order by')) { $q->order($this->getState('order by')); } else { $q->order($orderj . 'cat_position,cat_name'); } if ((int) $this->getState('brand_id')) { $q->where('c.cat_brand_id=:brand_id')->value(array('brand_id' => (int) $this->getState('brand_id'))); } if ($this->getState('val_values')) { foreach ($this->getState('val_values') as $vvId => $vvVal) { $q->where('EXISTS ( SELECT * FROM rad_cat_val_values WHERE vv_cat_id=c.cat_id AND vv_name_id=' . (int) $vvId . ' AND vv_value=:val_' . (int) $vvId . ' )')->value(array('val_' . (int) $vvId => $vvVal)); } } if ($this->getState('currency')) { $q->join('INNER', RAD . 'currency cur ON cur.cur_id=:currency')->value(array('currency' => $this->getState('currency'))); $q->select('(c.cat_cost*cr.cur_cost/cur.cur_cost) AS price'); } if ($this->getState('cost.from')) { $q->having('price >= :costfrom')->value(array('costfrom' => $this->getState('cost.from'))); } if ($this->getState('cost.to')) { $q->having('price <= :costto')->value(array('costto' => $this->getState('cost.to'))); } $limit = $this->getState('limit'); $limit = $limit ? ' LIMIT ' . $limit : ''; $i = 0; if ($this->getState('showSQL')) { print_h($q->getValues()); die($q->toString()); } foreach ($this->queryAll($q->toString() . $limit, $q->getValues()) as $row) { $result[$i] = new struct_corecatalog_catalog($row); $this->assignSpecial($result[$i]); if ($withvals) { $result[$i]->type_link = new struct_coremenus_tree($row); } $i++; } //foreach if (($withvals or $this->getState('val_values')) and count($result)) { $this->getValValues($result, $ct_showing); } return $result; } else { throw new rad_exception('Not setted the "cit_tre_id" or "tre_id!" in class "' . $this->getClassName() . '" at line: ' . __LINE__, 500); } }