Beispiel #1
0
foreach (test\db\Paginator::find($paginator, \ebi\Q::order('id')) as $o) {
    $i++;
}
eq(20, $i);
$i = 0;
$paginator = new \ebi\Paginator(20, 4);
foreach (test\db\Paginator::find($paginator, \ebi\Q::order('id')) as $o) {
    $i++;
}
eq(20, $i);
$i = 0;
$paginator = new \ebi\Paginator(20, 5);
foreach (test\db\Paginator::find($paginator, \ebi\Q::order('id')) as $o) {
    $i++;
}
eq(18, $i);
$i = 0;
$paginator = new \ebi\Paginator(20, 6);
foreach (test\db\Paginator::find($paginator, \ebi\Q::order('id')) as $o) {
    $i++;
}
eq(0, $i);
$i = 0;
$req = new \ebi\Request();
$req->vars('paginate_by', 30);
// 30を指定してもmax25なので25まで
$paginator = \ebi\Paginator::request($req, 20, 25);
foreach (test\db\Paginator::find($paginator, \ebi\Q::order('id')) as $o) {
    $i++;
}
eq(25, $i);
Beispiel #2
0
<?php

use ebi\Q;
\test\db\Find::find_delete();
(new \test\db\Find())->order(1)->value1('aaa')->value2('AAA')->updated('2014/10/04')->save();
(new \test\db\Find())->order(3)->value1('ccc')->value2('CCC')->updated('2014/10/06')->save();
(new \test\db\Find())->order(2)->value1('bbb')->value2('BBB')->updated('2014/10/05')->save();
$object_list = \test\db\Find::find_all(Q::order('order'));
eq('<object_list>' . '<Find><order>1</order><value1>aaa</value1><value2>AAA</value2><updated>2014-10-04T00:00:00+09:00</updated></Find>' . '<Find><order>2</order><value1>bbb</value1><value2>BBB</value2><updated>2014-10-05T00:00:00+09:00</updated></Find>' . '<Find><order>3</order><value1>ccc</value1><value2>CCC</value2><updated>2014-10-06T00:00:00+09:00</updated></Find>' . '</object_list>', (new \ebi\Xml('object_list', $object_list))->get());
Beispiel #3
0
<?php

$mail = new \ebi\Mail();
$mail->from('*****@*****.**');
$mail->to('*****@*****.**');
$mail->send('subject', 'body');
$dao = \ebi\SmtpBlackholeDao::find_get(\ebi\Q::order('-id'));
eq('subject', $dao->subject());
eq('body', $dao->message());
eq('*****@*****.**', $dao->to());
<?php

use ebi\Q;
\test\db\CompositePrimaryKeys::create_table();
\test\db\CompositePrimaryKeys::find_delete();
(new \test\db\CompositePrimaryKeys())->id1(1)->id2(1)->value('AAA1')->save();
(new \test\db\CompositePrimaryKeys())->id1(1)->id2(2)->value('AAA2')->save();
(new \test\db\CompositePrimaryKeys())->id1(1)->id2(3)->value('AAA3')->save();
(new \test\db\CompositePrimaryKeys())->id1(2)->id2(1)->value('BBB1')->save();
(new \test\db\CompositePrimaryKeys())->id1(2)->id2(2)->value('BBB2')->save();
(new \test\db\CompositePrimaryKeys())->id1(2)->id2(3)->value('BBB3')->save();
\test\db\CompositePrimaryKeysRef::create_table();
\test\db\CompositePrimaryKeysRef::find_delete();
(new \test\db\CompositePrimaryKeysRef())->ref_id(1)->type_id(1)->save();
(new \test\db\CompositePrimaryKeysRef())->ref_id(2)->type_id(1)->save();
(new \test\db\CompositePrimaryKeysRef())->ref_id(1)->type_id(2)->save();
(new \test\db\CompositePrimaryKeysRef())->ref_id(2)->type_id(2)->save();
$i = 0;
$r = [[1, 1, 'AAA1'], [2, 1, 'BBB1'], [1, 2, 'AAA2'], [2, 2, 'BBB2']];
foreach (\test\db\CompositePrimaryKeysRefValue::find(Q::order('type_id,id')) as $o) {
    eq($r[$i][0], $o->ref_id());
    eq($r[$i][1], $o->type_id());
    eq($r[$i][2], $o->value());
    $i++;
}
eq(4, $i);
Beispiel #5
0
}
foreach (\test\db\Find::find(Q::match('abc')) as $obj) {
    eq('abc', $obj->value1());
}
$i = 0;
$r = array('aaa', 'bbb', 'mno');
foreach (\test\db\Find::find(Q::neq('value1', 'ccc'), new \ebi\Paginator(1, 3), Q::order('-id')) as $obj) {
    eq(isset($r[$i]) ? $r[$i] : null, $obj->value1());
    $i++;
}
foreach (\test\db\Find::find(Q::neq('value1', 'abc'), new \ebi\Paginator(1, 3), Q::order('id')) as $obj) {
    eq('jkl', $obj->value1());
}
$i = 0;
$r = array('mno', 'aaa');
foreach (\test\db\Find::find(Q::neq('value1', 'ccc'), new \ebi\Paginator(1, 2), Q::order('order,-id')) as $obj) {
    eq(isset($r[$i]) ? $r[$i] : null, $obj->value1());
    $i++;
}
$result = \test\db\Find::find_all(Q::match('AAA'));
eq(3, sizeof($result));
$result = \test\db\Find::find_all(Q::match('AA'));
eq(3, sizeof($result));
$result = \test\db\Find::find_all(Q::eq('value2', null));
eq(1, sizeof($result));
$result = \test\db\Find::find_all(Q::neq('value2', null));
eq(7, sizeof($result));
$result = \test\db\Find::find_all(Q::eq('updated', null));
eq(6, sizeof($result));
$result = \test\db\Find::find_all(Q::neq('updated', null));
eq(2, sizeof($result));
Beispiel #6
0
$obj->save();
$obj = new \test\db\NewDao();
$obj->value('bbb');
$obj->save();
foreach (\test\db\NewDao::find() as $o) {
    neq(null, $o->value());
}
foreach (\test\db\NewDao::find(\ebi\Q::eq('value', 'aaa')) as $o) {
    eq('aaa', $o->value());
}
$obj = new \test\db\NewDao();
neq(null, $obj);
\test\db\NewDao::find_delete();
eq(0, \test\db\NewDao::find_count());
$obj = new \test\db\NewDao();
$obj->save();
$obj = new \test\db\NewDao();
$obj->value(null);
$obj->save();
$obj = new \test\db\NewDao();
$obj->value('');
$obj->save();
eq(1, \test\db\NewDao::find_count(Q::eq('value', '')));
eq(2, \test\db\NewDao::find_count(Q::eq('value', null)));
eq(3, \test\db\NewDao::find_count());
$r = array(null, null, '');
$i = 0;
foreach (\test\db\NewDao::find(Q::order('id')) as $o) {
    eq($r[$i], $o->value());
    $i++;
}
Beispiel #7
0
 /**
  * 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');
 }