Exemplo n.º 1
0
 public function __construct(DataRow $row)
 {
     if ($row->getTable()->getTableName() !== DB::getRoleTableName()) {
         throw new SystemException('Wrong Role Table');
     }
     $this->_data = $row->getAllData();
     //load permission
     $this->loadPermission();
 }
Exemplo n.º 2
0
 public function __construct(DataRow $row = null)
 {
     if ($row === null) {
         $this->_data = array('id' => 0, 'name' => '请选择科目');
         $this->setTable(new Table('subjects'));
     } else {
         $this->_data = $row->getAllData();
         $this->setTable($row->getTable());
     }
 }
 /**
  * append a datarow object to the list
  * @param DataRow $data
  * @return boolean false if data table not match
  */
 public function append(DataRow $data)
 {
     if ($data->getTable()) {
         if ($data->getTable()->getTableName() != $this->_table->getTableName()) {
             return false;
         }
     } else {
         $data->setTable($this->_table);
     }
     $this->_data[] = $data;
     return true;
 }
Exemplo n.º 4
0
 public function prepareDataRow(DataRow $data = null, array $properties = null)
 {
     if ($properties == null) {
         $properties = array();
         $ref = new \ReflectionObject($this);
         $ps = $ref->getProperties(\ReflectionProperty::IS_PUBLIC);
         foreach ($ps as $p) {
             $properties[] = $p->getName();
         }
     }
     if ($data == null) {
         $data = new DataRow();
     }
     foreach ($properties as $property) {
         $data->set($property, $this->{$property});
     }
     return $data;
 }
Exemplo n.º 5
0
 public function loadTable(Table $table, DataRow $dataRow = null)
 {
     $schema = $table->getSchema();
     $fields = $schema['fields'];
     $obj = new \ORC\MVC\Request\Object();
     foreach ($fields as $field_name => $field) {
         if (!isset($_REQUEST[$field_name])) {
             continue;
         }
         switch ($field['type']) {
             case 'smallint':
             case 'int':
             case 'mediumint':
                 if ($field['unsigned']) {
                     $filter = 'posint';
                 } else {
                     $filter = 'int';
                 }
                 break;
             case 'decimal':
                 $filter = 'numeric';
                 break;
             case 'enum':
                 $filter = array('enum' => $field['value']);
                 break;
             default:
                 $filter = 'safe';
                 break;
         }
         $default_value = null;
         if ($dataRow) {
             if ($dataRow->exists($field_name)) {
                 $default_value = $dataRow->get($field_name);
             }
         }
         $value = $this->applyFilter($_REQUEST[$field_name], $filter, $default_value);
         $this->set($field_name, $obj->{$field_name} = $value);
     }
     return $obj;
 }