public function main($argv) { Pix_Table::$_save_memory = true; list(, $type, $year, $month) = $argv; if (!in_array($type, array('company', 'bussiness', 'company-continue', 'bussiness-continue'))) { return $this->wrong_argv(); } if (in_array($type, array('company', 'bussiness'))) { $year = intval($year); $month = intval($month); if (!intval($year) or !intval($month)) { return $this->wrong_argv(); } } if ('company' == $type) { $ids = Crawler::crawlerMonth($year, $month); $ids = array_unique($ids); file_put_contents('ids', implode("\n", $ids)); foreach ($ids as $id) { $u = Updater::update($id); if ($u) { $u->updateSearch(); } } } elseif ('company-continue' == $type) { $ids = explode("\n", file_get_contents('ids')); $pos = array_search($year, $ids); var_dump($pos); if (false === $pos) { return $this->wrong_argv(); } foreach (array_slice($ids, $pos - 1) as $id) { $u = Updater::update($id); if ($u) { $u->updateSearch(); } } } else { $ids = Crawler::crawlerBussiness($year, $month); $ids = array_unique($ids); file_put_contents('ids', implode("\n", $ids)); foreach ($ids as $id) { $u = Updater::updateBussiness($id); if ($u) { $u->updateSearch(); } } } }
<?php include __DIR__ . '/../init.inc.php'; Pix_Table::$_save_memory = true; $ids = Updater::searchByKeyword($_SERVER['argv'][1]); foreach ($ids as $id) { if (Unit::find($id)) { continue; } Updater::update($id); Unit::find($id)->updateSearch(); } $ids = Updater::searchBussinessByKeyword($_SERVER['argv'][1]); foreach ($ids as $id) { if (Unit::find($id)) { continue; } if ($u = Updater::updateBussiness($id)) { $u->updateSearch(); } }