Ejemplo n.º 1
0
/**
 *	shorthand for the aql2array class
 *	@param string $aql
 *	@return array
 */
function aql2array($param1, $param2 = null)
{
    if (aql::is_aql($param1)) {
        $r = new aql2array($param1);
        return $r->aql_array;
    } else {
        return aql2array::get($param1, $param2);
    }
}
Ejemplo n.º 2
0
 /**
  * Creates and stores the parsed AQL array
  */
 public function makeAqlArray()
 {
     $m = $this->_model_name;
     if ($m == 'Model' || !$m) {
         $this->_aql_array = aql2array($this->_aql);
     } else {
         self::$_metadata[$m]['aql_array'] =& aql2array::get($m, $this->getStoredAql());
     }
 }
Ejemplo n.º 3
0
 /**
  * Executes a select query on the DB
  * @param   mixed   $aql        aql | model name | aql array
  * @param   array   $clause     clause array | true (for $obj)
  * @param   mixed   $obj        Boolean or object name
  * @param   string  $statement  If passing in an aql array, use this to also pass in
  *                              the aql statement
  * @param   Boolean $force      Force master DB read
  * @param   mixed   $conn       Specific DB connection
  * @return  array
  * @global  $is_dev
  * @throws  \Sky\AQL\Exception  if model not found
  */
 public function select($aql, $clause = array(), $obj = false, $statement = null, $force = false, $conn = null)
 {
     global $is_dev;
     $conn = $conn ?: self::getDB();
     $silent = aql::in_transaction();
     if (!is_array($clause) && $clause === true) {
         $obj = true;
     }
     if (!$aql) {
         return array();
     }
     if (is_array($aql)) {
         $aql_array = $aql;
     } else {
         if (self::is_aql($aql)) {
             $statement = $aql;
             $aql_array = aql2array($statement);
         } else {
             $m = $aql;
             $statement = self::get_aql($m);
             if (!$statement) {
                 $e = new \Sky\AQL\Exception(' AQL Error: Model ' . $m . ' is not defined. ' . PHP_EOL . "path/to/models/{$m}/{$m}.aql is empty or not found.");
                 if (!$silent) {
                     self::$errors[] = $e;
                     return array();
                 }
                 throw $e;
             }
             $aql_array = aql2array::get($m, $statement);
         }
     }
     if ($obj && !is_bool($obj) && $m) {
         $obj = $m;
     }
     if (is_array($clause)) {
         $clause = self::check_clause_array($aql_array, $clause);
     }
     if ($_GET['aql_debug'] && $is_dev) {
         print_a($aql_array);
     }
     $returned = self::make_sql_array($aql_array, $clause);
     if ($_GET['aql_debug'] && $is_dev) {
         print_a($returned);
     }
     if ($_GET['refresh']) {
         $force = true;
     }
     $params = array('object' => $obj, 'aql_statement' => $statement, 'sub_do_set' => $force);
     return self::sql_result($returned, $params, $conn);
 }