コード例 #1
0
ファイル: driver.class.php プロジェクト: jvirtism/AnEngine
 /**
  * Get result rows
  *
  * Returns all result rows as a two-dimensional array. Returns null if the
  * result is empty.If <var>$key</var> parameter is set, that field will be
  * used as an index for the results array.
  *
  * If {@link AeType::$wrapReturn} is true, this method returns {@link AeNull}
  * instead of null
  *
  * @param string $key index field name
  *
  * @return AeArray
  */
 public function getRows($key = null)
 {
     if ($this->getResult() === null && $this->getQuery()) {
         $this->execute();
     }
     if ($this->getResult() === null) {
         return AeType::wrapReturn(null);
     }
     if (!is_null($key)) {
         $key = (string) $key;
     }
     $return = array();
     while (AeType::of($row = $this->getRow()) != 'null') {
         if (!is_null($key) && isset($row[$key])) {
             $return[(string) $row[$key]] = $row;
             continue;
         }
         $return[] = $row;
     }
     $this->setResult(null);
     return AeType::wrapReturn($return);
 }
コード例 #2
0
ファイル: image.class.php プロジェクト: jvirtism/AnEngine
 /**
  * Get Mime type
  *
  * Returns an image's Mime type to be used with the Content-Type header
  *
  * @uses AeImage::_getMime()
  *
  * @return string
  */
 public function getMime()
 {
     if (!is_object($this->file)) {
         throw new AeImageException('No path value passed', 400);
     }
     return AeType::wrapReturn($this->_getMime($this->file->extension));
 }
コード例 #3
0
ファイル: array.class.php プロジェクト: jvirtism/AnEngine
 /**
  * Return offset value
  *
  * Method for the {@link ArrayAccess} interface implementation
  *
  * @throws AeArrayException #413 if offset does not exist
  *
  * @param mixed $offset
  *
  * @return mixed
  */
 public function offsetGet($offset)
 {
     if ($offset instanceof AeScalar) {
         $offset = $offset->getValue();
     }
     if (!$this->offsetExists($offset)) {
         throw new AeArrayException('Invalid offset value: offset does not exist', 413);
     }
     return AeType::wrapReturn($this->_value[$offset]);
 }
コード例 #4
0
ファイル: driver.class.php プロジェクト: jvirtism/AnEngine
 public function getSection($name = null)
 {
     if ($name === null) {
         return $this->_section;
     }
     $name = (string) $name;
     return AeType::wrapReturn(isset($this->_properties[$name]) ? $this->_properties[$name] : array());
 }
コード例 #5
0
ファイル: input.class.php プロジェクト: jvirtism/AnEngine
 public function getArray($name, $default = array(), $callback = null)
 {
     $value = $this->_getClean($name);
     if (is_array($value)) {
         if (!empty($callback)) {
             if (AeType::of($callback) != 'string') {
                 throw new AeInputException('Invalid callback value: expecting string, ' . AeType::of($callback) . ' given', 400);
             }
             $callback = (string) $callback;
             $method = 'get' . ucfirst($callback);
             if (!$this->methodExists($method)) {
                 throw new AeInputException('Invalid callback value: method not supported', 404);
             }
             foreach ($value as $k => $v) {
                 $key = $name . '.' . $k;
                 if (is_array($v)) {
                     $value[$k] = $this->getArray($key, $v, $callback);
                 } else {
                     $value[$k] = $this->call($method, array($key, $v));
                 }
             }
         }
     } else {
         $value = null;
     }
     return AeType::wrapReturn($value, $default);
 }
コード例 #6
0
ファイル: session.class.php プロジェクト: jvirtism/AnEngine
 /**
  * Get session variable
  *
  * Returns the session variable, identified by the <var>$name</var>
  * parameter, or the <var>$default</var>, if variable is not set or is null
  *
  * @uses AeSession::_check() to check for session state
  *
  * @throws AeSessionException #403 if session validation failed
  * @throws AeSessionException #408 if session has expired
  * @throws AeSessionException #412 if session has been destroyed
  *
  * @param string $name
  * @param mixed  $default
  *
  * @return object|AeScalar|AeArray
  */
 public function get($name, $default = null)
 {
     $name = (string) $name;
     if ($this->propertyExists($name)) {
         // *** Never wrap object properties
         return parent::get($name, $default);
     }
     $this->_check();
     if (!preg_match($this->_keyPattern, (string) $name)) {
         throw new AeSessionException('Key name is invalid', 400);
     }
     $return = $this->_getByKey((string) $name, $_SESSION);
     return AeType::wrapReturn($return, $default);
 }