当前位置: 首页>>代码示例>>PHP>>正文


PHP Q::eq方法代码示例

本文整理汇总了PHP中Q::eq方法的典型用法代码示例。如果您正苦于以下问题:PHP Q::eq方法的具体用法?PHP Q::eq怎么用?PHP Q::eq使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Q的用法示例。


在下文中一共展示了Q::eq方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: edit

 /**
  * ページ編集
  */
 public function edit($name)
 {
     $this->vars('name', $name);
     try {
         $current = C(WikiPage)->find_get(Q::eq('name', $name), Q::order('-version'));
     } catch (Exception $e) {
     }
     if ($this->is_post()) {
         try {
             $page = new WikiPage();
             $page->cp($this->vars());
             if (isset($current)) {
                 $page->version($current->version() + 1);
             }
             $page->save();
             C($page)->commit();
             $this->redirect_method('model', $name);
         } catch (Exception $e) {
             $this->vars('page', $page);
             $this->vars('body', $page->body());
         }
     } else {
         if (isset($current)) {
             $this->vars('page', $current);
             $this->vars('body', $current->body());
         } else {
             $default = new WikiPage();
             $default->name($name);
             $this->vars('page', $default);
             $this->vars('body', '*' . $name);
         }
     }
 }
开发者ID:riaf,项目名称:rhaco2-repository,代码行数:36,代码来源:Wiki.php

示例2: play

 function play($stage_id)
 {
     $stage = $this->dbUtil->get(new Stage(), new C(Q::eq(Stage::columnId(), $stage_id)));
     if (!Variable::istype('Stage', $stage)) {
         $this->_notFound();
         return $this->parser();
     }
     $this->setVariable('object', $stage);
     if ($this->isPost()) {
         // add comment
         $this->setVariable('stage_id', $stage->id);
         if ($this->dbUtil->insert($this->toObject(new Comment()))) {
             Header::redirect(Rhaco::url('play/' . $stage->id));
         }
     }
     $stage_file_name = Rhaco::path(sprintf('stages/%d.apif', $stage->id));
     $stage_data = unserialize(file_get_contents($stage_file_name));
     foreach ($stage_data as &$v) {
         if (preg_match('/^images.*?gif$/', $v['value'])) {
             $v['value'] = Rhaco::url($v['value']);
         }
     }
     $this->setVariable('stage_data', $stage_data);
     $this->setVariable('comments', $this->dbUtil->select(new Comment(), new C(Q::eq(Comment::columnStageId(), $stage->id))));
     return $this->parser('play.html');
 }
开发者ID:riaf,项目名称:concert,代码行数:26,代码来源:ConcertView.php

示例3: mark_all_as_read

 public function mark_all_as_read(OpenpearMaintainer $maintainer)
 {
     foreach (C(__CLASS__)->find_all(Q::eq('maintainer_to_id', $maintainer->id())) as $message) {
         $message->unread(false);
         $message->save();
     }
 }
开发者ID:nequal,项目名称:Openpear,代码行数:7,代码来源:OpenpearMessage.php

示例4: recount_favorites

 public static function recount_favorites($package_id)
 {
     try {
         $fav_count = C(OpenpearFavorite)->find_count(Q::eq('package_id', $package_id));
         $package = C(OpenpearPackage)->find_get(Q::eq('id', $package_id));
         $package->favored_count($fav_count);
         $package->save();
     } catch (Exception $e) {
     }
 }
开发者ID:nequal,项目名称:Openpear,代码行数:10,代码来源:OpenpearFavorite.php

示例5: maintainer

 public function maintainer()
 {
     if ($this->maintainer instanceof OpenpearMaintainer === false) {
         try {
             $this->maintainer = C(OpenpearMaintainer)->find_get(Q::eq('id', $this->maintainer_id()));
         } catch (Exception $e) {
         }
     }
     return $this->maintainer;
 }
开发者ID:nequal,项目名称:Openpear,代码行数:10,代码来源:OpenpearNewprojectQueue.php

示例6: isActive

 function isActive($db)
 {
     if ($this->private) {
         return ExceptionTrigger::raise(new GenericException('このイベントに参加することは出来ません'));
     }
     if ($this->periodDate < time()) {
         return ExceptionTrigger::raise(new GenericException('参加登録期限が過ぎています'));
     }
     if ($db->count(new Participant(), new C(Q::eq(Participant::columnEvent(), $this->id))) >= $this->maxParticipant) {
         return ExceptionTrigger::raise(new GenericException('参加登録可能人数を超えています'));
     }
     return true;
 }
开发者ID:riaf,项目名称:jp.rhaco-users.kaigi,代码行数:13,代码来源:Event.php

示例7: packages

 public function packages()
 {
     if (!empty($this->packages)) {
         return $this->packages;
     }
     $packages = array();
     try {
         $package_tags = C(OpenpearPackageTag)->find_all(Q::eq('tag_id', $this->id()));
         foreach ($package_tags as $package_tag) {
             $packages[] = $package_tag->package();
         }
     } catch (Exception $e) {
     }
     $this->packages = $packages;
     return $packages;
 }
开发者ID:nequal,项目名称:Openpear,代码行数:16,代码来源:OpenpearTag.php

示例8: 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();
     }
 }
开发者ID:nequal,项目名称:Openpear,代码行数:17,代码来源:OpenpearTimeline.php

示例9: packages

 public static function packages(OpenpearMaintainer $maintainer)
 {
     $store_key = array('charges_maintainer', $maintainer->id());
     if (Store::has($store_key, self::CACHE_TIMEOUT)) {
         $packages = Store::get($store_key);
     } else {
         try {
             $packages = array();
             $charges = C(OpenpearCharge)->find_all(Q::eq('maintainer_id', $maintainer->id()));
             foreach ($charges as $charge) {
                 $packages[] = $charge->package();
             }
         } catch (Exception $e) {
             $packages = array();
         }
         Store::set($store_key, $packages, self::CACHE_TIMEOUT);
     }
     return $packages;
 }
开发者ID:nequal,项目名称:Openpear,代码行数:19,代码来源:OpenpearCharge.php

示例10: get_maintainer

 /**
  * メンテナ情報を取得する
  * @param int $id
  * @param bool $cache
  * @return OpenpearMaintainar
  **/
 public static function get_maintainer($id, $cache = true)
 {
     $cache_key = self::cache_key($id);
     if ($cache) {
         Log::debug('cache on');
         if (isset(self::$cached_maintainers[$id])) {
             return self::$cached_maintainers[$id];
         } else {
             if (Store::has($cache_key)) {
                 $maintainer = Store::get($cache_key);
                 self::$cached_maintainers[$id] = $maintainer;
                 return $maintainer;
             }
         }
     }
     $maintainer = C(__CLASS__)->find_get(Q::eq('id', $id));
     Store::set($cache_key, $maintainer, OpenpearConfig::object_cache_timeout(3600));
     return $maintainer;
 }
开发者ID:nequal,项目名称:Openpear,代码行数:25,代码来源:OpenpearMaintainer.php

示例11: login_condition

 public function login_condition(Request $request)
 {
     if ($request->user() instanceof OpenpearMaintainer) {
         return true;
     }
     if ($request->is_post() && $request->is_vars('login') && $request->is_vars('password')) {
         try {
             $user = C(OpenpearMaintainer)->find_get(Q::ob(Q::b(Q::eq('name', $request->in_vars('login'))), Q::b(Q::eq('mail', $request->in_vars('login')))));
             if ($user instanceof OpenpearMaintainer) {
                 if ($user->certify($request->in_vars('password'))) {
                     $request->user($user);
                     return true;
                 } else {
                     Exceptions::add(new Exception('password is incorrect'), 'password');
                 }
             }
         } catch (Exception $e) {
             Log::debug($e);
         }
     }
     return false;
 }
开发者ID:nequal,项目名称:Openpear,代码行数:22,代码来源:OpenpearAccountModule.php

示例12: where_sql

 protected function where_sql(\ebi\Dao $dao, &$from, \ebi\Q $q, array $self_columns, $require_where = null, $alias = true)
 {
     if ($q->is_block()) {
         $vars = $and_block_sql = $or_block_sql = [];
         $where_sql = '';
         foreach ($q->ar_and_block() as $qa) {
             list($where, $var) = $this->where_sql($dao, $from, $qa, $self_columns, null, $alias);
             if (!empty($where)) {
                 $and_block_sql[] = $where;
                 $vars = array_merge($vars, $var);
             }
         }
         if (!empty($and_block_sql)) {
             $where_sql .= ' (' . implode(' and ', $and_block_sql) . ') ';
         }
         foreach ($q->ar_or_block() as $or_block) {
             list($where, $var) = $this->where_sql($dao, $from, $or_block, $self_columns, null, $alias);
             if (!empty($where)) {
                 $or_block_sql[] = $where;
                 $vars = array_merge($vars, $var);
             }
         }
         if (!empty($or_block_sql)) {
             $where_sql .= (empty($where_sql) ? '' : ' and ') . ' (' . implode(' or ', $or_block_sql) . ') ';
         }
         if (empty($where_sql)) {
             $where_sql = $require_where;
         } else {
             if (!empty($require_where)) {
                 $where_sql = '(' . $require_where . ') and (' . $where_sql . ')';
             }
         }
         return [$where_sql, $vars];
     }
     if ($q->type() == Q::MATCH && sizeof($q->ar_arg1()) > 0) {
         $query = new \ebi\Q();
         $target = $q->ar_arg2();
         $ob = $columns = [];
         foreach ($self_columns as $column) {
             if (empty($target) || in_array($column->name(), $target)) {
                 $columns[$column->name()] = $dao->prop_anon($column->name(), 'type');
             }
         }
         foreach ($columns as $cn => $ct) {
             $and = [];
             foreach ($q->ar_arg1() as $cond) {
                 $op = null;
                 if (substr($cond, 0, 1) == '-') {
                     $cond = substr($cond, 1);
                     $op = Q::NOT;
                 }
                 switch ($ct) {
                     case 'number':
                     case 'serial':
                     case 'integer':
                     case 'timestamp':
                     case 'date':
                     case 'time':
                     case 'intdate':
                         $and[] = Q::eq($cn, $cond, $op);
                         break;
                     case 'string':
                     case 'email':
                     case 'alnum':
                         $and[] = Q::contains($cn, $cond, $op);
                         break;
                     case 'boolean':
                     case 'mixed':
                     default:
                 }
             }
             if (!empty($and)) {
                 $ob[] = call_user_func_array(['\\ebi\\Q', 'b'], $and);
             }
         }
         $query->add(call_user_func_array(['\\ebi\\Q', 'ob'], $ob));
         return $this->where_sql($dao, $from, $query, $self_columns, null, $alias);
     }
     $and = $vars = [];
     foreach ($q->ar_arg2() as $base_value) {
         $or = [];
         foreach ($q->ar_arg1() as $column_str) {
             $value = $base_value;
             $column = $this->get_column($column_str, $self_columns);
             $column_alias = $this->column_alias_sql($column, $q, $alias);
             $is_add_value = true;
             switch ($q->type()) {
                 case Q::EQ:
                     if ($value === null) {
                         $is_add_value = false;
                         $column_alias .= ' is null';
                         break;
                     }
                     $column_alias .= ' = ' . ($value instanceof \ebi\Daq ? '(' . $value->unique_sql() . ')' : '?');
                     break;
                 case Q::NEQ:
                     if ($value === null) {
                         $is_add_value = false;
                         $column_alias .= ' is not null';
                         break;
//.........这里部分代码省略.........
开发者ID:tokushima,项目名称:ebi,代码行数:101,代码来源:DbConnector.php

示例13: DbUtil

<?php

require_once '__init__.php';
Rhaco::import('generic.Urls');
Rhaco::import('model.Todo');
Rhaco::import('model.Category');
$db = new DbUtil(Category::connection());
$patterns = array('^$' => array('class' => 'generic.Views', 'method' => 'read', 'args' => array(new Todo(), new C(Q::eq(Todo::columnClose(), false), Q::fact())), 'template' => 'list.html'), '^detail/(\\d+)$' => array('method' => 'detail', 'args' => array(new Todo(), new C(Q::fact()))), '^create$' => array('method' => 'create', 'args' => array(new Todo(), Rhaco::url())), '^update/(\\d+)$' => array('method' => 'update', 'args' => array(new Todo(), null, Rhaco::url())), '^delete/(\\d+)$' => array('method' => 'delete', 'args' => array(new Todo(), null, Rhaco::url())), '^cat/(\\d+)$' => array('method' => 'detail', 'args' => array(new Category(), new C(Q::depend()))));
$parser = Urls::parser($patterns, $db);
$parser->setVariable('categories', $db->select(new Category()));
$parser->write();
开发者ID:riaf,项目名称:gihyo-rhaco-intro-sample,代码行数:11,代码来源:index.php

示例14: build

 /**
  * パッケージのビルドとリリースを行う
  * @return void
  **/
 public function build()
 {
     $package = C(OpenpearPackage)->find_get(Q::eq('id', $this->package_id));
     $maintainer = C(OpenpearMaintainer)->find_get(Q::eq('id', $this->maintainer_id));
     $this->init_build_dir(work_path('build/' . $package->name() . '.' . date('YmdHis')));
     foreach (array('desc.txt', 'notes.txt', 'summary.txt') as $filename) {
         File::write($this->build_dir($filename), $package->description());
     }
     if ($package->is_external_repository()) {
         switch ($package->external_repository_type()) {
             case 'Git':
                 $cmd = 'git clone';
                 break;
             case 'Mercurial':
                 $cmd = 'hg clone';
                 break;
             case 'Subversion':
                 $cmd = 'svn export';
                 break;
             default:
                 throw new RuntimeException('unknown repository type');
         }
         $command = new Command(sprintf('%s %s %s', $cmd, escapeshellarg($package->external_repository()), escapeshellarg($this->build_dir('tmp'))));
     } else {
         // Openpear Repository
         $revision = is_numeric($this->revision) && $this->revision > 0 ? intval($this->revision) : 'HEAD';
         $repository_path = sprintf('%s/%s/trunk', OpenpearConfig::svn_root(), $package->name());
         $command = new Command(sprintf('svn export -r %s %s %s', $revision, escapeshellarg($repository_path), escapeshellarg($this->build_dir('tmp'))));
     }
     if ($command->end_code()) {
         throw new RuntimeException($command->stderr());
     }
     $build_path = $this->build_dir(implode('/', array('tmp', $this->build_path)));
     if (!File::exist($build_path)) {
         throw new RuntimeException(sprintf('build path is not found: %s', $build_path));
     }
     $mv = new Command(sprintf('mv %s %s', escapeshellarg($build_path), escapeshellarg($this->build_dir('src'))));
     if ($mv->stderr() || !is_dir($this->build_dir('src'))) {
         throw new RuntimeException('src dir is not found');
     }
     // ビルドする
     chdir($this->build_dir());
     $project = PEAR_PackageProjector::singleton()->load($this->build_dir());
     $project->configure($this->build_dir('build.conf'));
     $project->make();
     // リリースしたファイルはどこ?
     chdir($this->build_dir('release'));
     foreach (glob('*.tgz') as $filename) {
         $package_file = $this->build_dir('release') . '/' . $filename;
         break;
     }
     if (!file_exists($package_file)) {
         throw new RuntimeException('package file is not exists: ' . $package_file);
     }
     // サーバーに追加する
     $cfg = (include path('channel.config.php'));
     $server = new PEAR_Server2($cfg);
     $server->addPackage($package_file);
     // svn tag
     $build_conf = parse_ini_string($this->build_conf, true);
     $svn = new Command(sprintf('svn copy' . ' %s/%s/trunk/%s' . ' %s/%s/tags/%s-%s-%s' . ' -m "%s (%s-%s) (@%s)"' . ' --username openpear', OpenpearConfig::svn_root(), $package->name(), $this->build_path, OpenpearConfig::svn_root(), $package->name(), $build_conf['version']['release_ver'], $build_conf['version']['release_stab'], date('YmdHis'), 'package released', $build_conf['version']['release_ver'], $build_conf['version']['release_stab'], $maintainer->name()));
     // これ以降はエラーが起きてもドンマイ
     try {
         $release = new OpenpearRelease();
         $release->package_id($package->id());
         $release->maintainer_id($maintainer->id());
         $release->version($build_conf['version']['release_ver']);
         $release->version_stab($build_conf['version']['release_stab']);
         $release->notes($this->notes);
         $release->settings($this->build_conf);
         $release->save();
         $package->latest_release_id($release->id());
         $package->released_at(time());
         $package->save();
         $message_template = new Template();
         $message_template->vars('t', new Templf());
         $message_template->vars('package', $package);
         $message_template->vars('maintainer', $maintainer);
         $message = new OpenpearMessage('type=system');
         $message->maintainer_to_id($maintainer->id());
         $message->subject(trans('{1} package have been released.', $package->name()));
         $message->description($message_template->read('messages/released.txt'));
         $message->save();
     } catch (Exception $e) {
         Log::error($e);
     }
 }
开发者ID:nequal,项目名称:Openpear,代码行数:91,代码来源:OpenpearReleaseQueue.php

示例15: sync

 /**
  * DBの値と同じにする
  * @return $this
  */
 public function sync()
 {
     $query = new \ebi\Q();
     $query->add(new \ebi\Paginator(1, 1));
     foreach ($this->primary_columns() as $column) {
         $query->add(Q::eq($column->name(), $this->{$column->name()}()));
     }
     foreach (self::get_statement_iterator($this, $query) as $dao) {
         foreach (get_object_vars($dao) as $k => $v) {
             if ($k[0] != '_') {
                 $this->{$k}($v);
             }
         }
         return $this;
     }
     throw new \ebi\exception\NotFoundException('synchronization failed');
 }
开发者ID:tokushima,项目名称:ebi,代码行数:21,代码来源:Dao.php


注:本文中的Q::eq方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。