本文整理汇总了PHP中Kwf_Model_Abstract::clearAllRows方法的典型用法代码示例。如果您正苦于以下问题:PHP Kwf_Model_Abstract::clearAllRows方法的具体用法?PHP Kwf_Model_Abstract::clearAllRows怎么用?PHP Kwf_Model_Abstract::clearAllRows使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Kwf_Model_Abstract
的用法示例。
在下文中一共展示了Kwf_Model_Abstract::clearAllRows方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: tearDown
public function tearDown()
{
if ($this->_modelFoo) {
$this->_modelFoo->dropTable();
}
if ($this->_modelBar) {
$this->_modelBar->dropTable();
}
if ($this->_modelFooToBar) {
$this->_modelFooToBar->dropTable();
}
Kwf_Model_Abstract::clearAllRows();
}
示例2: valid
public function valid()
{
$ret = $this->_innerIterator->valid();
if (!$ret) {
$s = $this->_innerIterator->getSelect();
$s->limit($this->_packageSize, $this->_currentOffset);
$this->_currentOffset += $this->_packageSize;
//$this->_innerIterator->getModel()->clearRows();
Kwf_Model_Abstract::clearAllRows();
$this->_innerIterator->rewind();
$ret = $this->_innerIterator->valid();
}
return $ret;
}
示例3: postUpdate
public function postUpdate()
{
$cmps = Kwf_Component_Data_Root::getInstance()->getComponentsByClass('Kwc_List_ChildPages_Teaser_Component', array('ignoreVisible' => true));
$num = 0;
foreach ($cmps as $cmp) {
$num++;
if (count($cmps) > 20) {
echo "updating List ChildPages [{$num}/" . count($cmps) . "]...\n";
}
Kwf_Model_Abstract::getInstance('Kwc_List_ChildPages_Teaser_Model')->updatePages($cmp);
$s = new Kwf_Model_Select();
$s->whereEquals('component_id', $cmp->dbId);
foreach (Kwf_Model_Abstract::getInstance('Kwc_List_ChildPages_Teaser_Model')->getRows($s) as $row) {
$childPage = Kwf_Component_Data_Root::getInstance()->getComponentByDbId($row->target_page_id, array('ignoreVisible' => true, 'limit' => 1));
$row->visible = isset($childPage->row) && isset($childPage->row->visible) ? $childPage->row->visible : true;
}
Kwf_Model_Abstract::clearAllRows();
}
}
示例4: startAction
public function startAction()
{
$this->_helper->viewRenderer->setNoRender(true);
$model = Kwf_Model_Abstract::getInstance('Kwc_Newsletter_Model');
$procs = array();
while (true) {
$select = $model->select()->where(new Kwf_Model_Select_Expr_Or(array(new Kwf_Model_Select_Expr_Equal('status', 'start'), new Kwf_Model_Select_Expr_And(array(new Kwf_Model_Select_Expr_Equal('status', 'startLater'), new Kwf_Model_Select_Expr_LowerEqual('start_date', new Kwf_DateTime(time())))), new Kwf_Model_Select_Expr_Equal('status', 'sending'))));
$rows = $model->getRows($select);
$activeCountRows = count($rows);
foreach ($rows as $newsletterRow) {
if ($newsletterRow->status != 'sending') {
$newsletterRow->resume_date = date('Y-m-d H:i:s');
$newsletterRow->status = 'sending';
$newsletterRow->save();
}
if (!isset($procs[$newsletterRow->id])) {
$procs[$newsletterRow->id] = array();
}
//remove stopped processes (might stop because of memory limit or simply crash for some reason)
foreach ($procs[$newsletterRow->id] as $k => $p) {
if (!$p->isRunning()) {
if ($this->_getParam('debug')) {
echo "process " . $p->getPid() . " stopped...\n";
}
unset($procs[$newsletterRow->id][$k]);
}
}
$s = new Kwf_Model_Select();
$s->whereEquals('newsletter_id', $newsletterRow->id);
$s->whereNull('send_process_pid');
if (!$newsletterRow->getModel()->getDependentModel('Queue')->countRows($s)) {
$newsletterRow->status = 'finished';
$newsletterRow->save();
if ($this->_getParam('debug')) {
echo "Newsletter finished.\n";
}
//give send processes time to finish
sleep(5);
//delete "hanging" queue entries
$s = new Kwf_Model_Select();
$s->whereEquals('newsletter_id', $newsletterRow->id);
foreach ($newsletterRow->getModel()->getDependentModel('Queue')->getRows($s) as $queueRow) {
$newsletterRow->getModel()->getDependentModel('QueueLog')->createRow(array('newsletter_id' => $queueRow->newsletter_id, 'recipient_model' => $queueRow->recipient_model, 'recipient_id' => $queueRow->recipient_id, 'status' => 'failed', 'send_date' => date('Y-m-d H:i:s')))->save();
$msg = "Newsletter finished but queue entry with pid {$queueRow->send_process_pid} still exists: {$queueRow->recipient_id} {$queueRow->searchtext}";
$e = new Kwf_Exception($msg);
$e->logOrThrow();
echo $msg . "\n";
$queueRow->delete();
}
continue;
}
if ($this->_getParam('debug')) {
echo count($procs[$newsletterRow->id]) . " running processes\n";
}
$numOfProcesses = 1;
if ($newsletterRow->mails_per_minute == 'unlimited') {
$numOfProcesses = $this->_getParam('maxProcesses');
if (!$numOfProcesses) {
$numOfProcesses = 3;
}
}
while (count($procs[$newsletterRow->id]) < $numOfProcesses) {
$cmd = "php bootstrap.php newsletter send --newsletterId={$newsletterRow->id}";
if ($this->_getParam('debug')) {
$cmd .= " --debug";
}
if ($this->_getParam('benchmark')) {
$cmd .= " --benchmark";
}
if ($this->_getParam('verbose')) {
$cmd .= " --verbose";
}
$descriptorspec = array(1 => STDOUT, 2 => STDERR);
$p = new Kwf_Util_Proc($cmd, $descriptorspec);
$procs[$newsletterRow->id][] = $p;
if ($this->_getParam('debug')) {
echo "\n*** started new process with PID " . $p->getPid() . "\n";
echo $cmd . "\n";
}
sleep(3);
//don't start all processes at the same time
}
if ($this->_getParam('debug')) {
echo "Newletter {$newsletterRow->id}: currently sending with " . round($newsletterRow->getCurrentSpeed()) . " mails/min\n";
}
}
Kwf_Model_Abstract::clearAllRows();
if ($this->_getParam('debug')) {
echo "sleep 10 secs.\n";
}
sleep(10);
}
}
示例5: freeMemory
/**
* Tries to clear all cached data objects and row objects
*
* Usful when processing lot of components to avoid memory issues
*/
public function freeMemory()
{
$this->_freeMemory();
foreach ($this->_dataCache as $id => $c) {
if (isset($this->_dataCacheIgnoreVisible[$id])) {
unset($this->_dataCacheIgnoreVisible[$id]);
}
$c->_freeMemory();
}
foreach ($this->_dataCacheIgnoreVisible as $id => $c) {
$c->_freeMemory();
}
$this->_dataCache = array();
$this->_dataCacheIgnoreVisible = array();
$this->_componentsByClassCache = null;
$this->_componentsByDbIdCache = null;
$this->_generatorsForClassesCache = array();
//Kwf_Component_Generator_Abstract::clearInstances();
Kwf_Model_Abstract::clearAllRows();
if (function_exists('gc_collect_cycles')) {
gc_collect_cycles();
}
}
示例6: runAction
public function runAction()
{
$debug = $this->_getParam('debug');
if (file_exists('temp/shutdown-maintenance')) {
unlink('temp/shutdown-maintenance');
}
$lastDailyRun = null;
if (file_exists('temp/maintenance-daily-run')) {
$lastDailyRun = file_get_contents('temp/maintenance-daily-run');
if ($debug) {
echo "last daily run: " . date('Y-m-d H:i:s', $lastDailyRun) . "\n";
}
}
$lastHourlyRun = null;
if (file_exists('temp/maintenance-hourly-run')) {
$lastHourlyRun = file_get_contents('temp/maintenance-hourly-run');
if ($debug) {
echo "last hourly run: " . date('Y-m-d H:i:s', $lastHourlyRun) . "\n";
}
}
$dailyMaintenanceWindowStart = "01:00";
//don't set before 00:00
$dailyMaintenanceWindowEnd = "05:00";
$nextDailyRun = null;
$lastMinutelyRun = null;
while (true) {
if (!$nextDailyRun) {
if ($lastDailyRun && $lastDailyRun > strtotime($dailyMaintenanceWindowStart)) {
//today already run
//maintenance window of tomorrow
$nextDailyRun = rand(strtotime("tomorrow {$dailyMaintenanceWindowStart}"), strtotime("tomorrow {$dailyMaintenanceWindowEnd}"));
} else {
//not yet run or today not yet run
if (time() < strtotime($dailyMaintenanceWindowEnd)) {
//window not yet over for today
//maintenance window of today
$nextDailyRun = rand(max(time(), strtotime($dailyMaintenanceWindowStart)), strtotime($dailyMaintenanceWindowEnd));
} else {
//maintenance window of tomorrow
$nextDailyRun = rand(strtotime("tomorrow {$dailyMaintenanceWindowStart}"), strtotime("tomorrow {$dailyMaintenanceWindowEnd}"));
}
}
if ($debug) {
echo "Next daily run: " . date('Y-m-d H:i:s', $nextDailyRun) . "\n";
}
}
Kwf_Util_Maintenance_Dispatcher::executeJobs(Kwf_Util_Maintenance_Job_Abstract::FREQUENCY_SECONDS, $debug);
if (!$lastMinutelyRun || time() - $lastMinutelyRun > 60) {
$lastMinutelyRun = time();
Kwf_Util_Maintenance_Dispatcher::executeJobs(Kwf_Util_Maintenance_Job_Abstract::FREQUENCY_MINUTELY, $debug);
//discard connection to database to reconnect on next job run
//avoids problems with auto closed connections due to inactivity
if (function_exists('gc_collect_cycles()')) {
Kwf_Model_Abstract::clearAllRows();
Kwf_Model_Abstract::clearInstances();
gc_collect_cycles();
Kwf_Registry::getInstance()->offsetUnset('db');
Kwf_Registry::getInstance()->offsetUnset('dao');
}
}
Kwf_Component_Data_Root::getInstance()->freeMemory();
if (!$lastHourlyRun || time() - $lastHourlyRun > 3600) {
if ($debug) {
echo date('Y-m-d H:i:s') . " execute hourly jobs\n";
}
$lastHourlyRun = time();
file_put_contents('temp/maintenance-hourly-run', $lastHourlyRun);
Kwf_Util_Maintenance_Dispatcher::executeJobs(Kwf_Util_Maintenance_Job_Abstract::FREQUENCY_HOURLY, $debug);
}
Kwf_Component_Data_Root::getInstance()->freeMemory();
if (time() > $nextDailyRun) {
if ($debug) {
echo date('Y-m-d H:i:s') . " execute daily jobs\n";
}
$lastDailyRun = time();
file_put_contents('temp/maintenance-daily-run', $lastDailyRun);
$nextDailyRun = null;
Kwf_Util_Maintenance_Dispatcher::executeJobs(Kwf_Util_Maintenance_Job_Abstract::FREQUENCY_DAILY, $debug);
}
sleep(10);
}
}
示例7: testCreateRow
public function testCreateRow()
{
return;
//not yet implemented
$row = $this->_m->createRow();
$row->model = '1m';
//is that the only & best way to select the desired target model?
$row->save();
Kwf_Model_Abstract::clearAllRows();
$models = $this->_m->getUnionModels();
$this->assertEquals(4, $models['1m']->countRows(array()));
$s = new Kwf_Model_Select();
$this->assertEquals(7, $this->_m->countRows($s));
}