Exemplo n.º 1
0
 public function assign($var, $content)
 {
     if (empty($var)) {
         _error_::set(eTPL2, LVL_FATAL);
     }
     $this->values[$var] = $content;
 }
Exemplo n.º 2
0
 private function validateValues()
 {
     foreach ($this->lastQuery['values'] as $key => $valueGroup) {
         if (is_object($valueGroup)) {
             _error_::set(eORM4 . 'OBJECT in table ' . self::tablename() . ' field ' . $this->fields[$key], LVL_FATAL);
         }
         if (is_resource($valueGroup)) {
             _error_::set(eORM4 . 'RESOURCE in table ' . self::tablename() . ' field ' . $this->fields[$key], LVL_FATAL);
         }
         if (is_link($valueGroup)) {
             _error_::set(eORM4 . 'LINK in table ' . self::tablename() . ' field ' . $this->fields[$key], LVL_FATAL);
         }
         if (is_array($valueGroup)) {
             _error_::set(eORM4 . 'ARRAY in table ' . self::tablename() . ', then is transformed to JSON - field ' . $this->fields[$key], LVL_WARNING);
             $this->lastQuery['values'][$key] = json_encode($this->lastQuery['values'][$key]);
         }
     }
 }
Exemplo n.º 3
0
 public static function factory($array, $pk, $class)
 {
     if (!class_exists($class)) {
         _error_::set(E10 . ' class: ' . $class, LVL_FATAL);
     }
     if (empty($pk) or !is_array($array)) {
         _error_::set(E11 . ' pk: ' . $pk, LVL_FATAL);
     }
     $out = array();
     $i = 0;
     $chkPk = is_array($pk) ? $pk[0] : $pk;
     //if(!isset($array[0][$chkPk]))  _error_::set(E9.' class: '.$class.' iteration: Zero', LVL_WARNING);
     //else
     foreach ($array as $value) {
         if (!isset($value[$chkPk])) {
             _error_::set(E9 . ' class: ' . $class . ' iteration:' . $i, LVL_WARNING);
         }
         if (!is_array($pk)) {
             $out[] = new $class($value[$pk]);
         } else {
             $array_constructor = array();
             foreach ($pk as $ipk) {
                 $array_constructor[] = $value[$ipk];
             }
             $out[] = new $class($array_constructor);
         }
         $i++;
     }
     return $out;
 }