Exemplo n.º 1
0
 public function __construct($class_name)
 {
     $this->class = Reflections::instance()->add($class_name)->get($class_name);
     // if connection name property is null the connection manager will use the default connection
     $connection = $this->class->getStaticPropertyValue('connection', null);
     $this->conn = ConnectionManager::get_connection($connection);
     $this->set_table_name();
     $this->get_meta_data();
     $this->set_primary_key();
     $this->set_sequence_name();
     $this->set_delegates();
     $this->set_setters_and_getters();
     $this->callback = new CallBack($class_name);
     $this->callback->register('before_save', function (Model $model) {
         $model->set_timestamps();
     }, array('prepend' => true));
     $this->callback->register('after_save', function (Model $model) {
         $model->reset_dirty();
     }, array('prepend' => true));
 }
Exemplo n.º 2
0
 public function reestablish_connection($close = true)
 {
     // if connection name property is null the connection manager will use the default connection
     $connection = $this->class->getStaticPropertyValue('connection', null);
     if ($close) {
         ConnectionManager::drop_connection($connection);
         static::clear_cache();
     }
     return $this->conn = ConnectionManager::get_connection($connection);
 }