当前位置: 首页>>代码示例>>PHP>>正文


PHP Doctrine::createTablesFromArray方法代码示例

本文整理汇总了PHP中Doctrine::createTablesFromArray方法的典型用法代码示例。如果您正苦于以下问题:PHP Doctrine::createTablesFromArray方法的具体用法?PHP Doctrine::createTablesFromArray怎么用?PHP Doctrine::createTablesFromArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Doctrine的用法示例。


在下文中一共展示了Doctrine::createTablesFromArray方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: setup

 public function setup()
 {
     $db = $this->databasemanager->getDatabase('doctrine');
     /* @var $db sfDoctrineDatabase */
     // Special Handling for postgre, since droping even when closing the connection, fails with
     // SQLSTATE[55006]: Object in use: 7 ERROR:  database "cs_doctrine_act_as_sortable_test" is being accessed by other users DETAIL:  There are 1 other session(s) using the database.
     if ($db->getDoctrineConnection() instanceof Doctrine_Connection_Pgsql) {
         try {
             $db->getDoctrineConnection()->createDatabase();
         } catch (Exception $e) {
         }
         $export = new Doctrine_Export_Pgsql($db->getDoctrineConnection());
         $import = new Doctrine_Import_Pgsql($db->getDoctrineConnection());
         $tablenames = array(SortableArticleTable::getInstance()->getTableName(), SortableArticleUniqueByTable::getInstance()->getTableName(), SortableArticleCategoryTable::getInstance()->getTableName());
         foreach ($tablenames as $tablename) {
             if ($import->tableExists($tablename)) {
                 $export->dropTable($tablename);
             }
         }
     } else {
         try {
             // ignore error if database does not yet exist (clean CI-env)
             $db->getDoctrineConnection()->dropDatabase();
         } catch (Exception $e) {
         }
         $db->getDoctrineConnection()->createDatabase();
     }
     // Using Doctrine instead of Doctrine_Core keeps it symfony 1.2 compatible, which uses
     Doctrine::loadModels(dirname(__FILE__) . '/../fixtures/project/lib/model/doctrine', Doctrine::MODEL_LOADING_CONSERVATIVE);
     Doctrine::createTablesFromArray(Doctrine::getLoadedModels());
     Doctrine::loadData(dirname(__FILE__) . '/../fixtures/project/data/fixtures/categories.yml');
 }
开发者ID:robo47,项目名称:csDoctrineActAsSortablePlugin-1,代码行数:32,代码来源:sfPluginTestBootstrap.class.php

示例2: execute

 /**
  * @see sfTask
  */
 protected function execute($arguments = array(), $options = array())
 {
     $this->logSection('doctrine', 'created tables successfully');
     $databaseManager = new sfDatabaseManager($this->configuration);
     Doctrine::loadModels(sfConfig::get('sf_lib_dir') . '/model/doctrine', Doctrine::MODEL_LOADING_CONSERVATIVE);
     Doctrine::createTablesFromArray(Doctrine::getLoadedModels());
 }
开发者ID:yasirgit,项目名称:afids,代码行数:10,代码来源:sfDoctrineInsertSqlTask.class.php

示例3: testCachedResultsAreSpecificToDsn

 public function testCachedResultsAreSpecificToDsn()
 {
     $cacheDriver = new Doctrine_Cache_Array();
     $conn1 = Doctrine_Manager::connection('sqlite::memory:', 'conn_1');
     $conn1->setAttribute(Doctrine::ATTR_RESULT_CACHE, $cacheDriver);
     $conn2 = Doctrine_Manager::connection('sqlite::memory:', 'conn_2');
     $conn2->setAttribute(Doctrine::ATTR_RESULT_CACHE, $cacheDriver);
     $this->assertNotEqual($conn1, $conn2);
     $manager = Doctrine_Manager::getInstance();
     $manager->setCurrentConnection('conn_1');
     $this->assertEqual($conn1, Doctrine_Manager::connection());
     Doctrine::createTablesFromArray(array('Ticket_1706_User'));
     $user = new Ticket_1706_User();
     $user->name = 'Allen';
     $user->save();
     $manager->setCurrentConnection('conn_2');
     $this->assertEqual($conn2, Doctrine_Manager::connection());
     Doctrine::createTablesFromArray(array('Ticket_1706_User'));
     $user = new Ticket_1706_User();
     $user->name = 'Bob';
     $user->save();
     $manager->setCurrentConnection('conn_1');
     $u1 = Doctrine_Query::create()->from('Ticket_1706_User u')->useResultCache()->execute();
     $this->assertEqual(1, count($u1));
     $this->assertEqual('Allen', $u1[0]->name);
     $manager->setCurrentConnection('conn_2');
     $u2 = Doctrine_Query::create()->from('Ticket_1706_User u')->useResultCache()->execute();
     $this->assertEqual(1, count($u2));
     $this->assertEqual('Bob', $u2[0]->name);
 }
开发者ID:swk,项目名称:bluebox,代码行数:30,代码来源:1706TestCase.php

示例4: migrate

 public function migrate()
 {
     $conn = Doctrine_Manager::connection();
     if (!$conn->import->tableExists('simple_route')) {
         Doctrine::createTablesFromArray(array('SimpleRoute'));
         $this->postInstall();
     }
 }
开发者ID:swk,项目名称:bluebox,代码行数:8,代码来源:configure.php

示例5: setUpCarsAndDrivers

 public function setUpCarsAndDrivers()
 {
     Doctrine::createTablesFromArray(array('Car', 'Driver'));
     $bmw = new Car();
     $bmw->make = 'BMW';
     $bmw->save();
     $this->cars['bmw'] = $bmw;
     $audi = new Car();
     $audi->make = 'Audi';
     $audi->save();
     $this->cars['audi'] = $audi;
     $kiro = new Driver();
     $kiro->name = 'Kiril Zyapkov';
     $kiro->save();
     $this->drivers['kiro'] = $kiro;
     $emo = new Driver();
     $emo->name = 'Emil Ivanov';
     $emo->save();
     $this->drivers['emo'] = $emo;
 }
开发者ID:vladev,项目名称:zend-form-doctrine,代码行数:20,代码来源:RelationsTest.php

示例6: testGeneratorComponentBinding

 public function testGeneratorComponentBinding()
 {
     Doctrine_Manager::connection('sqlite::memory:', 'test_tmp_conn', false);
     Doctrine_Manager::getInstance()->bindComponent('I18nGeneratorComponentBinding', 'test_tmp_conn');
     Doctrine::createTablesFromArray(array('I18nGeneratorComponentBinding'));
     try {
         $i = new I18nGeneratorComponentBinding();
         $i->name = 'test';
         $i->Translation['EN']->title = 'en test';
         $i->Translation['FR']->title = 'fr test';
         $i->save();
         $this->pass();
         $this->assertTrue($i->id > 0);
         $this->assertEqual($i->Translation['EN']->title, 'en test');
         $this->assertEqual($i->Translation['FR']->title, 'fr test');
         $this->assertEqual($i->getTable()->getConnection()->getName(), $i->Translation->getTable()->getConnection()->getName());
     } catch (Exception $e) {
         $this->fail($e->getMessage());
     }
 }
开发者ID:swk,项目名称:bluebox,代码行数:20,代码来源:GeneratorTestCase.php

示例7: install

 /**
  * Do the actual installation.
  *
  * Make sure you rollback any changes if your install fails (using uninstall())!
  *
  * By default, the install routine just installs your models. If that's all you need for your install,
  * you don't need to override this function. All models in the directory of your module will be installed.
  *
  * You do not need to override this class if you are not adding additional functionality to it.
  *
  * @return array | NULL Array of failures, or NULL if everything is OK
  */
 public function install($identifier)
 {
     $package = Package_Catalog::getPackageByIdentifier($identifier);
     if (!empty($package['directory']) and $package['type'] != Package_Manager::TYPE_CORE) {
         kohana::log('debug', 'Dynamically adding `' . $package['directory'] . '` to kohana');
         $loadedModules = Kohana::config('core.modules');
         $modules = array_unique(array_merge($loadedModules, array($package['directory'])));
         Kohana::config_set('core.modules', $modules);
         if (is_dir($package['directory'] . '/hooks')) {
             // Since we're running late, we need to go grab
             // the hook files again (sad but true)
             $hooks = Kohana::list_files('hooks', TRUE, $package['directory'] . '/hooks');
             foreach ($hooks as $file) {
                 // Load the hook
                 include_once $file;
             }
         }
     }
     // If this package has any models, load them and determine which ones are BASE models (i.e. not extensions of other models)
     // Note that we do this because Postgers & Doctrine don't like our polymorphic class extensions and try to create the same
     // tables twice.
     if (!empty($package['models'])) {
         $loadedModels = Doctrine::loadModels($package['directory'] . '/models', Doctrine::MODEL_LOADING_CONSERVATIVE);
     }
     if (!empty($loadedModels)) {
         $models = array();
         foreach ($loadedModels as $modelName) {
             if (get_parent_class($modelName) == 'Bluebox_Record' or get_parent_class($modelName) == 'Doctrine_Record') {
                 $models[] = $modelName;
             }
         }
         // If this package has any models of it's own (not extensions) then create the tables!
         if (!empty($models)) {
             kohana::log('debug', 'Adding table(s) ' . implode(', ', $models));
             Doctrine::createTablesFromArray($models);
         }
     }
 }
开发者ID:swk,项目名称:bluebox,代码行数:50,代码来源:Bluebox_Configure.php

示例8: catch

}
try {
    $tbl = Doctrine::getTable($modelname);
} catch (Exception $e) {
    echo "Error!\n" . $e->getMessage() . "\n";
    exit(1);
}
try {
    $conn->execute('describe ' . $tbl->getTableName());
    echo "Table already exists in database!\nDrop table and recreate? (y/n) > ";
    $drop = strtolower(trim(fgets(STDIN)));
    if ($drop == 'y') {
        try {
            $conn->execute('drop table ' . $tbl->getTableName());
        } catch (Exception $e) {
            echo "Unable to drop table! - " . $e->getMessage() . "\n";
            exit(1);
        }
    } else {
        exit(0);
    }
} catch (Exception $e) {
    // table doesn't exist --- good!
}
echo "Creating table ... ";
try {
    Doctrine::createTablesFromArray(array($tbl->getClassnameToReturn()));
    echo "Success!\n";
} catch (Exception $e) {
    echo "Error!\n" . $e->getMessage() . "\n";
}
开发者ID:kaakshay,项目名称:audience-insight-repository,代码行数:31,代码来源:create-tbl.php

示例9: createTablesFromArray

 /**
  * 
  * Initialize the database
  * @return void
  */
 public function createTablesFromArray()
 {
     $models = $this->_getModels();
     Doctrine::createTablesFromArray($models);
 }
开发者ID:KasaiDot,项目名称:FansubCMS,代码行数:10,代码来源:DoctrineTool.php

示例10: dirname

<?php

/**
 * Script for creating and loading database
 */
include_once dirname(__FILE__) . '/../../../application/bootstrap.php';
echo 'Generating models from schemas' . PHP_EOL;
try {
    Doctrine::generateModelsFromYaml('user.yml', APPLICATION_PATH . '/models');
    Doctrine::createTablesFromArray(array('User'));
} catch (Exception $e) {
    echo 'AN ERROR HAS OCCURED:' . PHP_EOL;
    echo $e->getMessage() . PHP_EOL;
    return false;
}
// Generally speaking, this script will be run from the command line
return true;
开发者ID:RobertGresdal,项目名称:robbiegee-code-samples,代码行数:17,代码来源:generate-db.php

示例11: dirname

 * the License, or (at your option) any later version.
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this software; if not, write to the Free
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
 */
/**
 * Document this file.
 *
 * @author Jason Kinner <jkinner@ringsidenetworks.com>
 */
require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . '/../config.php';
require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . '/../quiz.class.php';
require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . '/../answer.class.php';
try {
    $dm = Doctrine_Manager::getInstance();
    $dm->openConnection($db_url);
    //      print join(";\n", Doctrine::generateSqlFromArray(
    Doctrine::createTablesFromArray(array('Quiz', 'Answer'));
    //      )).";\n";
    print "Done\n";
} catch (Exception $e) {
    print $e->getMessage() . "\n";
    error_log($e->getTraceAsString());
}
开发者ID:jkinner,项目名称:ringside,代码行数:31,代码来源:createdb.php


注:本文中的Doctrine::createTablesFromArray方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。