Ejemplo n.º 1
0
$ghi = (new \test\db\Find())->order(1)->value1('ghi')->value2('GHI')->updated('2008/12/24 10:00:00')->save();
$jkl = (new \test\db\Find())->order(2)->value1('jkl')->value2('EDC')->save();
$aaa = (new \test\db\Find())->order(2)->value1('aaa')->value2('AAA')->updated('2008/12/24 10:00:00')->save();
$bbb = (new \test\db\Find())->order(2)->value1('bbb')->value2('Aaa')->save();
$ccc = (new \test\db\Find())->order(2)->value1('ccc')->value2('aaa')->save();
$mno = (new \test\db\Find())->order(2)->value1('mno')->value2(null)->save();
eq(8, \test\db\Find::find_count());
eq(8, sizeof(\test\db\Find::find_all()));
eq(5, sizeof(\test\db\Find::find_all(Q::eq('order', 2))));
eq(3, sizeof(\test\db\Find::find_all(Q::eq('order', 2), Q::eq('value2', 'aaa', Q::IGNORE))));
$sub1 = (new \test\db\SubFind())->value('abc')->order(4)->save();
$sub2 = (new \test\db\SubFind())->value('def')->order(3)->save();
$sub3 = (new \test\db\SubFind())->value('ghi')->order(1)->save();
$sub4 = (new \test\db\SubFind())->value('jkl')->order(2)->save();
eq(4, sizeof(\test\db\Find::find_all(Q::in('value1', \test\db\SubFind::find_sub('value')))));
eq(3, sizeof(\test\db\Find::find_all(Q::in('value1', \test\db\SubFind::find_sub('value', Q::gte('order', 2))))));
// --
\test\db\RefFind::find_delete();
$ref1 = (new \test\db\RefFind())->parent_id($abc->id())->save();
$ref2 = (new \test\db\RefFind())->parent_id($def->id())->save();
$ref3 = (new \test\db\RefFind())->parent_id($ghi->id())->save();
$ref4 = (new \test\db\RefFind())->parent_id($jkl->id())->save();
eq(4, sizeof(\test\db\RefFind::find_all()));
eq(1, sizeof(\test\db\RefFind::find_all(Q::eq('value', 'def'))));
eq(1, sizeof(\test\db\RefFind::find_all(Q::eq('value2', 'EDC'))));
eq(1, sizeof(\test\db\RefFindExt::find_all(Q::eq('value', 'def'))));
eq(1, sizeof(\test\db\RefFindExt::find_all(Q::eq('value2', 'EDC'))));
eq(1, sizeof(\test\db\RefFindExt::find_all(Q::eq('order', 3))));
eq(4, sizeof(\test\db\HasFind::find_all()));
$has1 = \test\db\HasFind::find_get(Q::eq('parent_id', $ref3->parent_id()));
if (eq(true, $has1->parent() instanceof \test\db\Find)) {
Ejemplo n.º 2
0
Archivo: Dt.php Proyecto: tokushima/ebi
 /**
  * SmtpBlackholeDaoから送信されたメールの一番新しいものを返す
  * @param string $to
  * @param string $tcode
  * @param string $keyword
  * @return \ebi\SmtpBlackholeDao
  */
 public static function find_mail($to, $tcode = '', $keyword = '')
 {
     $q = new Q();
     $q->add(Q::eq('to', $to));
     $q->add(Q::gte('create_date', time() - 300));
     if (!empty($tcode)) {
         $q->add(Q::eq('tcode', $tcode));
     }
     foreach (\ebi\SmtpBlackholeDao::find($q, Q::order('-id')) as $mail) {
         $value = $mail->subject() . $mail->message();
         if (empty($keyword) || mb_strpos($value, $keyword) !== false) {
             return $mail;
         }
     }
     throw new \ebi\exception\NotFoundException('mail not found');
 }