Skip to content

Instantly share code, notes, and snippets.

@Osukaru
Created October 4, 2012 13:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Osukaru/3833591 to your computer and use it in GitHub Desktop.
Save Osukaru/3833591 to your computer and use it in GitHub Desktop.
//En FIC_Backend_Model_Episode
public function getMissingSlugEpisodes()
{
$episodes = array();
$select = $this->select(true)
->where("episode_slug = ''");
$episodes = $select->query()->fetchAll();
return $episodes;
}
// En el proceso
<?php
// Define path to application directory
defined('APPLICATION_PATH')
|| define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../../application'));
// Define application environment
defined('APPLICATION_ENV')
|| define('APPLICATION_ENV', (isset($argv[1]) ? $argv[1] : 'production'));
// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
realpath(APPLICATION_PATH . '/../library'),
get_include_path(),
)));
/** Zend_Application */
require_once 'Zend/Application.php';
// Create application, bootstrap, and run
$application = new Zend_Application(
APPLICATION_ENV,
APPLICATION_PATH . '/configs/application.ini'
);
$application->bootstrap();
$resources = $application->getBootstrap()->getOption('resources');
// Begin
$episode = new FIC_Backend_Model_Episode;
$episodes = $episode->getMissingSlugEpisodes();
foreach ($episodes as $ep) {
$options = array('field' => 'episode_slug', 'model' => $episode);
$options['conditions'] = 'episode_serie_id = ' . $ep['episode_serie_id'];
$slug = new FIC_Backend_Filter_Slug($options);
if ($ep['episode_title'] !== '' && $ep['episode_title'] !== '-') {
$ep['episode_slug'] = $slug->filter($ep['episode_title']);
} else {
$ep['episode_slug'] = $slug->filter('episode-'.$ep['episode_season'].$ep['episode_number']);
}
$episode->update(array('episode_slug' => $ep['episode_slug']), 'episode_id = ' . $ep['episode_id']);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment