/** * returns an array of ids * @param array $clause clause array * @param Boolean $do_count if true, returns a count of the list * @return array * @throws \Exception if this is not a subclasss */ public static function getList($clause = array(), $do_count = false) { $model_name = self::getCalledClass(); if (!$model_name || $model_name == 'Model') { throw new Exception('Cannot use getList on a non subclass of Model.'); } $fn = \getList::getFn(\aql::get_aql($model_name)); return $fn($clause, $do_count); }
/** * Fetches the aql array by name or creates it and stores it * @param string $model * @param string $aql * @return array */ public static function get($model, $aql = null) { if (!$model || $model == 'model') { return array(); } if (self::$aqlArrays[$model]) { return self::$aqlArrays[$model]; } else { if (!$aql) { if (self::$aqls[$model]) { $aql = self::$aqls[$model]; } else { $aql = self::$aqls[$model] = aql::get_aql($model); } } return self::$aqlArrays[$model] = aql2array($aql); } }
case 'h1': $title = 'h1'; $where[] = "field = 'h1'"; break; case 'h1_blurb': $title = 'h1_blurb'; $where[] = "field = 'h1_blurb'"; break; case 'meta_description': $title = 'meta_description'; $where[] = "field = 'meta_description'"; break; default: // tab_redirect() ensures this is never the case break; } $title = "Website Page Data"; template::inc('intranet', 'top'); ?> <?php snippet::tabs($tabs); $aql = aql::get_aql('website_page_data'); $cols = "\n\t\t\tnickname {label: Nickname;}\n\t\t\tfield {label: field;}\n\t\t\tvalue {label: value;}\t\t\n\t"; $clause = array('website' => array('where' => $where, 'order by' => $order_by)); $options = array('enable_sort' => true); ?> <?php aql::grid($aql, $cols, $clause, $options); template::inc('intranet', 'bottom');
function collection($model, $clause, $duration = null) { $key = "aql:get:{$model}:" . substr(md5(serialize($clause)), 0, 250); $collection = mem($key); if (!$collection) { $aql = aql::get_aql($model); // make minimal sql $aql_array = aql2array($aql); foreach ($aql_array as $i => $block) { unset($aql_array[$i]['objects']); unset($aql_array[$i]['fields']); unset($aql_array[$i]['subqueries']); } $sql_array = aql::make_sql_array($aql_array, aql::check_clause_array($aql_array, $clause)); $minimal_sql = $sql_array['sql']; $r = sql($minimal_sql); $collection = array(); while (!$r->EOF) { $collection[] = $r->Fields(0); $r->MoveNext(); } #print_a($collection); mem($key, $collection, $duration); } if (is_array($collection)) { //print_a($collection); foreach ($collection as $id) { $obj = Model::get($model, $id); $ret[] = $obj->dataToArray(); } return $ret; } else { return false; } }
private function checkProfile($piece, $i, $file, $path) { // find primary_table via model if it is specified if ($this->settings['model']) { $aql = \aql::get_aql($this->settings['model']); $this->settings['primary_table'] = \aql::get_primary_table($aql); } // throw error if no primary_table if (!$this->settings['primary_table']) { header("HTTP/1.1 503 Service Temporarily Unavailable"); header("Status: 503 Service Temporarily Unavailable"); header("Retry-After: 1"); throw new \Exception('Profile Page Error: $primary_table not specified on file. <br />' . $file); return false; } // set to profile $decrypted = \decrypt($piece, $this->settings['primary_table']); if ($piece == 'add-new' || is_numeric($decrypted)) { $this->addToPageAndPath($file, $path, $i); return true; } return false; }