create() public method

Create a new, empty instance of the class. Used to add a new row to your database. May optionally be passed an associative array of data to populate the instance. If so, all fields will be flagged as dirty so all will be saved to the database when save() is called.
public create ( $data = null )
Beispiel #1
0
 public function createmodels()
 {
     if (!auth::check(self::AUTH_REALM)) {
         $this->access_denied();
     }
     $created = 0;
     $models = $this->getModels();
     foreach ($models as $id => $model) {
         if (!$model['status']) {
             $created++;
             $filename = substr($model['info']['basename'], 0, strpos($model['info']['basename'], '.xml'));
             ORM::create($filename);
         }
     }
     $this->msg = "<strong>{$created} models</strong> created successfuly.";
     $this->database();
 }
Beispiel #2
0
 /**
  * Wrap Idiorm's create method to return an
  * empty instance of the class associated with
  * this wrapper instead of the raw ORM class.
  *
  *  return ORMWrapper|bool
  */
 public function create($data = null)
 {
     return $this->_create_model_instance(parent::create($data));
 }
Beispiel #3
0
 public function create(Validation $validation = null)
 {
     $this->token = $this->create_token();
     return parent::create($validation);
 }
Beispiel #4
0
 /**
  * Insert a new object to the database
  * @param  Validation $validation Validation object
  * @return ORM
  */
 public function create(Validation $validation = NULL)
 {
     parent::create($validation);
     $this->reload_config();
 }
Beispiel #5
0
 public function create(Validation $validation = NULL)
 {
     $user = user::get();
     $this->user_id = $user->id;
     $this->created = $user->timestamp();
     $this->day = user::get()->today_slug();
     return parent::create($validation);
 }
Beispiel #6
0
 /**
  * Wrap Idiorm's create method to return an
  * empty instance of the class associated with
  * this wrapper instead of the raw ORM class.
  *
  * @param array $data associate array of data to fill the model
  *
  * @return Model
  */
 public function create($data = null)
 {
     return $this->createModelInstance(parent::create($data));
 }
Beispiel #7
0
 /**
  * Override the create method with defaults
  *
  * @param   Validation $validation  Validation object [Optional]
  *
  * @return  ORM
  *
  * @throws  Gleez_Exception
  */
 public function create(Validation $validation = NULL)
 {
     if ($this->_loaded) {
         throw new Gleez_Exception('Cannot create :model model because it is already loaded.', array(':model' => $this->_object_name));
     }
     $this->init = $this->mail;
     $this->status = 1;
     return parent::create($validation);
 }
Beispiel #8
0
     $block = ORM::factory('blocktype')->where('contenttype_id', '=', $this->content->contenttype_id)->where('key', '=', $key)->find();
     if ((bool) $block->loaded()) {
         $block = $this->blocks->where('blocktype_id', '=', $block->id)->find_all();
         if ((bool) $block->count()) {
             return $block;
         }
     }
     return false;
 }
 // alias
 public function get_block($key)
 {
     return $this->get_block_by_key($key);
 }
 public function get_blocks()
 {
     return $this->blocks->where('parent', '=', $this->id)->find_all();
 }
 public function create(Validation $validation = NULL)
 {
Beispiel #9
0
 /**
  * Saves the current object. Will hash password if it was changed.
  *
  * @return  ORM
  */
 public function save()
 {
     if (array_key_exists('password', $this->_changed)) {
         $this->_object['password'] = Auth::instance()->hash_password($this->_object['password']);
     }
     if (isset($this->_object['id'])) {
         return parent::update();
     } else {
         return parent::create();
     }
 }
Beispiel #10
0
 public function create(Validation $validation = NULL)
 {
     $this->created = time();
     return parent::create($validation);
 }