本文整理汇总了PHP中Kwf_Model_Select::whereNull方法的典型用法代码示例。如果您正苦于以下问题:PHP Kwf_Model_Select::whereNull方法的具体用法?PHP Kwf_Model_Select::whereNull怎么用?PHP Kwf_Model_Select::whereNull使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Kwf_Model_Select
的用法示例。
在下文中一共展示了Kwf_Model_Select::whereNull方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _getSelect
protected function _getSelect($row)
{
$ret = new Kwf_Model_Select();
foreach ($this->_groupBy as $k => $field) {
if (is_array($field)) {
$values = $field;
$field = $k;
$valueFound = false;
foreach ($values as $value) {
if ($row->{$field} == $value) {
$valueFound = true;
$ret->whereEquals($field, $value);
break;
}
}
if (!$valueFound) {
$ret->whereNotEquals($field, $values);
}
} else {
if (is_null($row->{$field})) {
$ret->whereNull($field);
} else {
$ret->whereEquals($field, $row->{$field});
}
}
}
return $ret;
}
示例2: 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);
}
}
示例3: _convertSelectForSibling
private function _convertSelectForSibling($select, $m)
{
$s = new Kwf_Model_Select();
if ($p = $select->getPart(Kwf_Model_Select::WHERE_EQUALS)) {
foreach ($p as $f => $v) {
if (!in_array($f, $this->_getOwnColumns()) && $m->hasColumn($f)) {
$s->whereEquals($f, $v);
}
}
}
if ($p = $select->getPart(Kwf_Model_Select::WHERE_NOT_EQUALS)) {
foreach ($p as $f => $v) {
if (!in_array($f, $this->_getOwnColumns()) && $m->hasColumn($f)) {
$s->whereNotEquals($f, $v);
}
}
}
if ($p = $select->getPart(Kwf_Model_Select::WHERE_NULL)) {
foreach ($p as $f) {
if (!in_array($f, $this->_getOwnColumns()) && $m->hasColumn($f)) {
$s->whereNull($f);
}
}
}
if ($p = $select->getPart(Kwf_Model_Select::WHERE_EXPRESSION)) {
foreach ($p as $expr) {
$e = $this->_convertExprForSibling($expr, $m);
if ($e) {
$s->where($e);
}
}
}
return $s;
}
示例4: testCountSelectWhereNull
public function testCountSelectWhereNull()
{
$s = new Kwf_Model_Select();
$s->whereNull('foo');
$this->assertEquals(0, $this->_m->countRows($s));
}