![]() |
|
Snippets |
|
To use database connections defined in the databases.yml configuration file, you can use the following snippet:
// initialize database manager $databaseManager = new sfDatabaseManager(); $databaseManager->initialize();
Create a batch/load_data.php script with:
<?php define('SF_ROOT_DIR', realpath(dirname(__FILE__).'/..')); define('SF_APP', 'frontend'); define('SF_ENVIRONMENT', 'dev'); define('SF_DEBUG', true); require_once(SF_ROOT_DIR.DIRECTORY_SEPARATOR.'apps'.DIRECTORY_SEPARATOR.SF_APP.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'config.php'); // initialize database manager $databaseManager = new sfDatabaseManager(); $databaseManager->initialize(); $data = new sfPropelData(); $data->loadData(sfConfig::get('sf_data_dir').DIRECTORY_SEPARATOR.'fixtures'); ?>
Call it with:
$ cd batch
$ php load_data.php
It will load the data contained in all the .yml files of the data/fixtures/ directory.