Example #1
0
 /**
  * Get the Intermediate table
  * @param 
  */
 protected function getIntermediate()
 {
     $args = func_get_args();
     //
     $args = Table::sort($args);
     return $args[0] . '_' . $args[1];
 }
Example #2
0
 function __construct($name)
 {
     $this->reelName = $name;
     $this->name = $this->setName($name);
     //
     $columns = Database::read("select COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = '" . Config::get('database.database') . "' AND TABLE_NAME = '" . $this->name . "';");
     //
     foreach ($columns as $key => $value) {
         Table::push($this->columns, $value['COLUMN_NAME']);
     }
 }
Example #3
0
 /**
  * Get first row of data selected by where clause 
  **/
 public function first()
 {
     if (!empty($this->data)) {
         if (Table::count($this->data) > 0) {
             return $this->data[0];
         } else {
             return null;
         }
     } else {
         return null;
     }
 }
Example #4
0
 public static function join($array, $separator, $startIndex = 0, $count = -1)
 {
     $string = "";
     //
     $end = $count == -1 ? Table::count($array) : $count;
     //
     for ($i = $startIndex; $i < $end; $i++) {
         if ($i == $end - 1) {
             $string .= $array[$i];
         } else {
             echo $string .= $array[$i] . $separator;
         }
     }
     //
     return $string;
 }
Example #5
0
 public static function alert($message, $data = array())
 {
     self::log("Alert : " . $message);
     if (!empty($data)) {
         self::log(self::tabulation() . Table::toString($data), false);
     }
 }
Example #6
0
 protected static function getSchemas($root, $bundle)
 {
     $f = glob($root . "app/bundles/{$bundle}/schemas/*.php");
     $sch = array();
     //
     foreach ($f as $value) {
         $t = explode("/", $value);
         $t = $t[Table::count($t) - 1];
         $t = explode(".php", $t);
         $t = $t[0];
         $sch[] = $t;
     }
     //
     return $sch;
 }
Example #7
0
 /**
  * preparing the data for the hasone relation
  * @param $model : data of the raltion
  * @param $remote : the model wanted to be related to the 
  *			current model
  */
 protected function prepare($models)
 {
     return !is_null($models->data) ? Table::count($models->data) > 0 ? Table::count($models->data) == 1 ? $models->data[0] : $models->data : null : null;
 }
Example #8
0
 protected static function diffResource($only, $except)
 {
     $all = array('index', 'show', 'add', 'insert', 'edit', 'update', 'delete');
     //
     if (isset($except)) {
         $i = 0;
         foreach ($all as $value) {
             if (Table::contains($except, $value)) {
                 unset($all[$i]);
             }
             $i++;
         }
     }
     //
     if (isset($only)) {
         foreach ($all as $key => $value) {
             $ext = false;
             foreach ($only as $value2) {
                 if ($value == $value2) {
                     $ext = true;
                     break;
                 }
             }
             if (!$ext) {
                 unset($all[$key]);
             }
         }
     }
     return $all;
 }
Example #9
0
 /**
  * preparing the data for the hasone relation
  * @param $model : data of the raltion
  * @param $remote : the model wanted to be related to the 
  *			current model
  */
 protected function prepare($model, $remote)
 {
     return !empty($model) ? isset($model->data) ? Table::count($model->data) == 1 ? $model->data[0] : $this->ManyRelationException($remote) : null : null;
 }
Example #10
0
 public static function user()
 {
     if (self::check()) {
         if (Session::existe('auths')) {
             $user = new \User(Session::get("auths")[0]);
             //
             return $user;
         } else {
             if (Cookie::existe(Config::get('auth.rememeber_cookie'))) {
                 $usr = new \User();
                 $user = Table::first($usr->get("rememberToken", Cookie::get(Config::get('auth.rememeber_cookie'))));
                 //
                 return $user;
             }
         }
     } else {
         return null;
     }
 }