* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. * * Import into sf_news_cache, starting from already populated tables. * Since this script cleans the sf_news_cache table, use with extreme care. * It can be used in order to re-build all the news. */ define('SF_ROOT_DIR', realpath(dirname(__FILE__) . '/..')); define('SF_APP', 'fe'); define('SF_ENVIRONMENT', 'prod'); define('SF_DEBUG', true); require_once SF_ROOT_DIR . DIRECTORY_SEPARATOR . 'apps' . DIRECTORY_SEPARATOR . SF_APP . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'config.php'; sfContext::getInstance(); // uncomment to clean all news NewsPeer::doDeleteAll(); // define all news generators and the corresponding date fields (null = no field) for sorting purposes $generators = array('OppCaricaHasAtto' => OppCaricaHasAttoPeer::DATA, 'OppVotazioneHasAtto' => null, 'OppDocumento' => OppDocumentoPeer::DATA, 'OppAttoHasIter' => OppAttoHasIterPeer::DATA, 'OppAttoHasSede' => null, 'OppIntervento' => OppInterventoPeer::DATA, 'OppAtto' => OppAttoPeer::DATA_PRES, 'OppCaricaHasGruppo' => OppCaricaHasGruppoPeer::DATA_INIZIO, 'OppCarica' => OppCaricaPeer::DATA_INIZIO); $tot_cnt = 0; foreach ($generators as $model => $date_field) { echo "Importing from {$model} "; $c = new Criteria(); // extract the number of items to process for the generator $n_todo = call_user_func_array(array($model . 'Peer', 'doCount'), array($c)); echo "({$n_todo}) "; // get table map and columns map for this generator $model_table = call_user_func($model . 'Peer::getTableMap'); $model_columns = $model_table->getColumns(); // find and store primary keys $pks = array(); foreach ($model_columns as $column) {