예제 #1
0
 public static function main()
 {
     \org\rhaco\Log::info('main');
     $obj = new \test\model\TestModelLog();
     $obj->run();
     foreach (\test\model\TestModel::find(new \org\rhaco\Paginator(1), \org\rhaco\store\db\Q::order('-id')) as $o) {
         \org\rhaco\Log::info($o->id());
         $o->number(100);
         $o->save();
     }
     $dao = new \test\model\TestModel();
     $dao->number(1);
     $dao->save();
 }
예제 #2
0
파일: Dt.php 프로젝트: tokushima/rhaco3
 /**
  * SmtpBlackholeDaoから送信されたメールの一番新しいものを返す
  * @param string $to
  * @param string $subject
  * @param number $late_time sec
  * @throws \LogicException
  * @return \org\rhaco\net\mail\module\SmtpBlackholeDao
  */
 public static function find_mail($to, $keyword = null, $late_time = 60)
 {
     if (empty($to)) {
         throw new \LogicException('`to` not found');
     }
     $result = array();
     $q = new Q();
     $q->add(Q::eq('to', $to));
     $q->add(Q::gte('create_date', time() - $late_time));
     if (!empty($subject)) {
         $q->add(Q::contains('subject', $subject));
     }
     foreach (\org\rhaco\net\mail\module\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 \LogicException('指定のメールが飛んでいない > [' . $to . '] ' . $keyword);
 }
예제 #3
0
파일: new.php 프로젝트: tokushima/rhaco3
<?php

use org\rhaco\store\db\Q;
\test\model\NewDao::create_table();
$obj = new \test\model\NewDao();
neq(null, $obj);
\test\model\NewDao::find_delete();
eq(0, \test\model\NewDao::find_count());
$obj = new \test\model\NewDao();
$obj->save();
$obj = new \test\model\NewDao();
$obj->value(null);
$obj->save();
$obj = new \test\model\NewDao();
$obj->value('');
$obj->save();
eq(1, \test\model\NewDao::find_count(Q::eq('value', '')));
eq(2, \test\model\NewDao::find_count(Q::eq('value', null)));
eq(3, \test\model\NewDao::find_count());
$r = array(null, null, '');
$i = 0;
foreach (\test\model\NewDao::find(Q::order('id')) as $o) {
    eq($r[$i], $o->value());
    $i++;
}
예제 #4
0
파일: all.php 프로젝트: tokushima/rhaco3
    try {
        $result[0]->value("fuga");
        $result[0]->save();
        eq("fuga", $result[0]->value());
    } catch (\BadMethodCallException $e) {
        fail();
    }
}
\test\model\CompositePrimaryKeys::create_table();
\test\model\CompositePrimaryKeysRef::create_table();
\test\model\CompositePrimaryKeys::find_delete();
$ref(new \test\model\CompositePrimaryKeys())->id1(1)->id2(1)->value('AAA1')->save();
$ref(new \test\model\CompositePrimaryKeys())->id1(1)->id2(2)->value('AAA2')->save();
$ref(new \test\model\CompositePrimaryKeys())->id1(1)->id2(3)->value('AAA3')->save();
$ref(new \test\model\CompositePrimaryKeys())->id1(2)->id2(1)->value('BBB1')->save();
$ref(new \test\model\CompositePrimaryKeys())->id1(2)->id2(2)->value('BBB2')->save();
$ref(new \test\model\CompositePrimaryKeys())->id1(2)->id2(3)->value('BBB3')->save();
\test\model\CompositePrimaryKeysRef::find_delete();
$ref(new \test\model\CompositePrimaryKeysRef())->ref_id(1)->type_id(1)->save();
$ref(new \test\model\CompositePrimaryKeysRef())->ref_id(2)->type_id(1)->save();
$ref(new \test\model\CompositePrimaryKeysRef())->ref_id(1)->type_id(2)->save();
$ref(new \test\model\CompositePrimaryKeysRef())->ref_id(2)->type_id(2)->save();
$i = 0;
$r = array(array(1, 1, 'AAA1'), array(2, 1, 'BBB1'), array(1, 2, 'AAA2'), array(2, 2, 'BBB2'));
foreach (\test\model\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);
예제 #5
0
파일: Dao.php 프로젝트: tokushima/rhaco3
 /**
  * @module org.rhaco.store.queue.Queue
  * 終了したものを削除する
  * @param string $type
  * @param timestamp $fin
  */
 public function clean($type, $fin, \org\rhaco\Paginator $paginator)
 {
     foreach (\org\rhaco\store\queue\module\Dao\QueueDao::find(Q::eq('type', $type), Q::neq('fin', null), Q::lte('fin', $fin), Q::order('id'), $paginator) as $obj) {
         $obj->delete();
     }
     \org\rhaco\store\queue\module\Dao\QueueDao::commit();
 }
예제 #6
0
파일: find.php 프로젝트: tokushima/rhaco3
}
foreach (\test\model\Find::find(Q::match("abc")) as $obj) {
    eq("abc", $obj->value1());
}
$i = 0;
$r = array("aaa", "bbb", "mno");
foreach (\test\model\Find::find(Q::neq("value1", "ccc"), new \org\rhaco\Paginator(1, 3), Q::order("-id")) as $obj) {
    eq(isset($r[$i]) ? $r[$i] : null, $obj->value1());
    $i++;
}
foreach (\test\model\Find::find(Q::neq("value1", "abc"), new \org\rhaco\Paginator(1, 3), Q::order("id")) as $obj) {
    eq("jkl", $obj->value1());
}
$i = 0;
$r = array("mno", "aaa");
foreach (\test\model\Find::find(Q::neq("value1", "ccc"), new \org\rhaco\Paginator(1, 2), Q::order("order,-id")) as $obj) {
    eq(isset($r[$i]) ? $r[$i] : null, $obj->value1());
    $i++;
}
$result = \test\model\Find::find_all(Q::match("AAA", Q::IGNORE));
eq(3, sizeof($result));
$result = \test\model\Find::find_all(Q::match("AA", Q::IGNORE));
eq(3, sizeof($result));
$result = \test\model\Find::find_all(Q::eq("value2", null));
eq(1, sizeof($result));
$result = \test\model\Find::find_all(Q::neq("value2", null));
eq(7, sizeof($result));
$result = \test\model\Find::find_all(Q::eq("updated", null));
eq(6, sizeof($result));
$result = \test\model\Find::find_all(Q::neq("updated", null));
eq(2, sizeof($result));
예제 #7
0
파일: Dao.php 프로젝트: tokushima/rhaco3
 /**
  * サブクエリを取得する
  * @param $name 対象のプロパティ
  * @return \org\rhaco\store\db\Daq
  */
 public static final function find_sub($name)
 {
     $args = func_get_args();
     array_shift($args);
     $dao = new static();
     $query = new Q();
     $query->add($dao->__find_conds__());
     if (!empty($args)) {
         call_user_func_array(array($query, 'add'), $args);
     }
     if (!$query->is_order_by()) {
         $query->order($name);
     }
     $paginator = $query->paginator();
     if ($paginator instanceof \org\rhaco\Paginator) {
         if ($query->is_order_by()) {
             $paginator->order($query->in_order_by(0)->ar_arg1(), $query->in_order_by(0)->type() == Q::ORDER_ASC);
         }
         $paginator->total(call_user_func_array(array(get_called_class(), 'find_count'), $args));
         if ($paginator->total() == 0) {
             return array();
         }
     }
     /**
      * SELECT文の生成
      * @param self $dao
      * @param org.rhaco.store.db.Q $query
      * @param org.rhaco.Paginator $paginator
      * @param string $name
      * @return org.rhaco.store.db.Daq
      */
     return static::module('select_sql', $dao, $query, $paginator, $name);
 }