Ejemplo n.º 1
0
 function createTableOnTheFly($model_name, $fields)
 {
     $table_name = AkInflector::tableize($model_name);
     $Installer = new AkInstaller();
     $Installer->dropTable($table_name, array('sequence' => true));
     $Installer->createTable($table_name, $fields, array('timestamp' => false));
 }
Ejemplo n.º 2
0
 public function _createJoinTable()
 {
     $options = $this->getOptions($this->association_id);
     require_once AK_LIB_DIR . DS . 'AkInstaller.php';
     $Installer = new AkInstaller();
     $Installer->createTable($options['join_table'], "id,{$options['foreign_key']},{$options['association_foreign_key']}", array('timestamp' => false));
     return $this->JoinObject->setTableName($options['join_table'], false);
 }
Ejemplo n.º 3
0
 protected function _reinstallModel($model, $table_definition = '')
 {
     $this->log('Reinstalling model:' . $model);
     if (!$this->uninstallAndInstallMigration($model)) {
         $table_name = AkInflector::tableize($model);
         if (empty($table_definition)) {
             Ak::import($model);
             if (class_exists($model)) {
                 $Instance = new $model();
                 if ($table_name != $Instance->getTableName()) {
                     // skipping, table inheritance
                     return;
                 }
             }
             trigger_error(Ak::t('Could not install the table %tablename for the model %modelname', array('%tablename' => $table_name, '%modelname' => $model)), E_USER_ERROR);
             return false;
         }
         $installer = new AkInstaller();
         $installer->skip_db_sql = true;
         $installer->dropTable($table_name, array('sequence' => true));
         $installer->createTable($table_name, $table_definition, array('timestamp' => false));
     } else {
         $table_name = AkInflector::tableize($model);
     }
     if (isset($this->fixtures) && is_array($this->fixtures) && in_array($table_name, $this->fixtures)) {
         $this->_loadFixtures($table_name);
     }
 }
Ejemplo n.º 4
0
 static function install()
 {
     $db = Ak::db();
     if (!$db->tableExists('sessions')) {
         $Installer = new AkInstaller($db);
         $Installer->createTable('sessions', '
                                     id string(32) not null primary key,
                                     expire datetime,
                                     value text', array('timestamp' => false));
     }
 }
Ejemplo n.º 5
0
 static function install()
 {
     $db = Ak::db();
     if (!$db->tableExists('cache')) {
         $Installer = new AkInstaller($db);
         $Installer->createTable('cache', '
     id string(65) not null index primary key unique,
     cache_group string(50) index,
     cache_data binary,
     expire datetime');
     }
 }