本文整理汇总了PHP中Q::in方法的典型用法代码示例。如果您正苦于以下问题:PHP Q::in方法的具体用法?PHP Q::in怎么用?PHP Q::in使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Q
的用法示例。
在下文中一共展示了Q::in方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: dashboard
/**
* ダッシュボード
* @context OpenpearMaintainer $maintainer ログインしてるメンテナ
* @context OpenpearCharge[] $my_package_charges
* @context OpenpearTimeline[] $timelines
* @context OpenpearFavorite[] $my_favorites
* @context OpenpearMessage[] $notices
*/
public function dashboard()
{
$this->vars('maintainer', $this->user());
$this->vars('my_packages', C(OpenpearPackage)->find_all(Q::in('id', C(OpenpearCharge)->find_sub('package_id', Q::eq('maintainer_id', $this->user()->id()))), Q::order('-updated')));
$this->vars('timelines', OpenpearTimeline::get_by_maintainer($this->user()));
$this->vars('fav_packages', C(OpenpearPackage)->find_all(Q::in('id', C(OpenpearFavorite)->find_sub('package_id', Q::eq('maintainer_id', $this->user()->id()))), Q::order('-updated')));
$this->vars('notices', C(OpenpearMessage)->find_all(Q::eq('maintainer_to_id', $this->user()->id()), Q::eq('type', 'system_notice'), Q::eq('unread', true)));
}
示例2: get_by_maintainer
public static function get_by_maintainer(OpenpearMaintainer $maintainer, $limit = 20)
{
try {
$favorites = C(OpenpearFavorite)->find_all(Q::eq('maintainer_id', $maintainer->id()));
$charges = C(OpenpearCharge)->find_all(Q::eq('maintainer_id', $maintainer->id()));
$ids = array();
foreach ($favorites as $f) {
$ids[] = $f->package_id();
}
foreach ($charges as $c) {
$ids[] = $c->package_id();
}
return C(OpenpearTimeline)->find_all(new Paginator($limit), Q::in('package_id', array_unique($ids)), Q::order('-id'));
} catch (Exception $e) {
return array();
}
}
示例3: find_all
/**
* 検索結果をすべて取得する
*
* @return array Dao
*/
public final function find_all()
{
$this->verify_class_access("call C(DAO_CLASS)->find_all()");
$args = func_get_args();
$result = array();
$it = call_user_func_array(array($this, "find"), $args);
$has_many_column = array();
$is_has_many = !empty($this->_has_many_conds_);
foreach ($it as $p) {
if ($is_has_many) {
foreach ($this->_has_many_conds_ as $name => $conds) {
$has_many_column[$name][] = $p->{$conds[2]}();
}
}
$result[] = $p;
}
if ($is_has_many) {
foreach ($this->_has_many_conds_ as $name => $conds) {
foreach ($conds[0]->find(Q::in($conds[1], $has_many_column[$name])) as $dao) {
foreach ($result as $self_dao) {
if ($dao->{$conds[1]}() === $self_dao->{$conds[2]}()) {
$self_dao->{$name}($dao);
}
}
}
}
}
return $result;
/***
# test
create_tmp_table("test_1","test_dao_find",array("id"=>"serial","value"=>"string","value2"=>"string","updated"=>"timestamp","order"=>"number"));
class TestDaoFind extends Dao{
static protected $__id__ = "type=serial";
static protected $__order__ = "type=number";
static protected $__updated__ = "type=timestamp";
protected $id;
protected $order;
protected $value;
protected $value2;
protected $updated;
}
R(new TestDaoFind("value=abc,updated=2008/12/24 10:00:00,order=4"))->save();
R(new TestDaoFind("value=def,updated=2008/12/24 10:00:00,order=3"))->save();
R(new TestDaoFind("value=ghi,updated=2008/12/24 10:00:00,order=1"))->save();
R(new TestDaoFind("value=jkl,updated=2008/12/24 10:00:00,order=2"))->save();
R(new TestDaoFind("value=aaa,updated=2008/12/24 10:00:00,order=2"))->save();
eq(5,sizeof(C(TestDaoFind)->find_all()));
foreach(C(TestDaoFind)->find(Q::eq("value","abc")) as $obj){
eq("abc",$obj->value());
}
$paginator = new Paginator(1,2);
eq(1,sizeof($result = C(TestDaoFind)->find_all(Q::neq("value","abc"),$paginator)));
eq("ghi",$result[0]->value());
eq(4,$paginator->total());
$i = 0;
foreach(C(TestDaoFind)->find(
Q::eq("value","abc"),
Q::or_block(
Q::eq("id",2),
Q::or_block(
Q::eq("value","ghi")
)
),
Q::neq("value","aaa")
) as $obj){
$i++;
}
eq(3,$i);
$list = array("abc","def","ghi","jkl","aaa");
$i = 0;
foreach(C(TestDaoFind)->find() as $obj){
eq($list[$i],$obj->value());
eq("2008/12/24 10:00:00",$obj->fmUpdated());
$i++;
}
foreach(C(TestDaoFind)->find(Q::eq("value","AbC",Q::IGNORE)) as $obj){
eq("abc",$obj->value());
}
foreach(C(TestDaoFind)->find(Q::neq("value","abc")) as $obj){
neq("abc",$obj->value());
}
try{
C(TestDaoFind)->find(Q::eq("value_error","abc"));
eq(false,true);
}catch(Exception $e){
eq(true,true);
}
try{
$dao = new TestDaoFind();
$dao->find(Q::eq("value_error","abc"));
eq(false,true);
//.........这里部分代码省略.........
示例4: getActiveCategories
/**
* 活発なカテゴリを取得する
* @param int $limit
* @return array OpenpearTag[]
**/
public static function getActiveCategories($limit = 10)
{
$tag_ids_count = C(OpenpearPackageTag)->find_count_by('package_id', 'tag_id', Q::eq('prime', true));
arsort($tag_ids_count);
if (count($tag_ids_count) == 0) {
$categories = array();
} else {
$categories = C(OpenpearTag)->find_all(Q::in('id', array_slice(array_keys($tag_ids_count), 0, $limit)));
}
return $categories;
}
示例5: maintainer_profile
/**
* メンテナのプロフィール
* @param string $maintainer_name メンテナのアカウント名
* @context OpenpearMaintainer $object メンテナ
* @context OpenpearCharge[] $charges
* @context OpenpearFavorite[] $favorites
* @context OpenpearTimeline[] $timelines
*/
public function maintainer_profile($maintainer_name)
{
try {
$maintainer = C(OpenpearMaintainer)->find_get(Q::eq('name', $maintainer_name));
} catch (NotfoundDaoException $e) {
$this->not_found($e);
} catch (Exception $e) {
// 共通エラーに飛ばす
throw $e;
}
$this->vars('object', $maintainer);
$this->vars('packages', C(OpenpearPackage)->find_all(Q::in('id', C(OpenpearCharge)->find_sub('package_id', Q::eq('maintainer_id', $maintainer->id()))), Q::order('-updated')));
$this->vars('fav_packages', C(OpenpearPackage)->find_all(Q::in('id', C(OpenpearFavorite)->find_sub('package_id', Q::eq('maintainer_id', $maintainer->id()))), Q::order('-updated')));
$this->vars('timelines', C(OpenpearTimeline)->find_all(new Paginator(10), Q::eq('maintainer_id', $maintainer->id()), Q::order('-created')));
}