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


PHP queryfx_one函数代码示例

本文整理汇总了PHP中queryfx_one函数的典型用法代码示例。如果您正苦于以下问题:PHP queryfx_one函数的具体用法?PHP queryfx_one怎么用?PHP queryfx_one使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: processRequest

 public function processRequest()
 {
     $request = $this->getRequest();
     $pager = new AphrontPagerView();
     $pager->setOffset($request->getInt('page'));
     $macro_table = new PhabricatorFileImageMacro();
     $macros = $macro_table->loadAllWhere('1 = 1 ORDER BY id DESC LIMIT %d, %d', $pager->getOffset(), $pager->getPageSize());
     // Get an exact count since the size here is reasonably going to be a few
     // thousand at most in any reasonable case.
     $count = queryfx_one($macro_table->establishConnection('r'), 'SELECT COUNT(*) N FROM %T', $macro_table->getTableName());
     $count = $count['N'];
     $pager->setCount($count);
     $pager->setURI($request->getRequestURI(), 'page');
     $rows = array();
     foreach ($macros as $macro) {
         $src = PhabricatorFileURI::getViewURIForPHID($macro->getFilePHID());
         $rows[] = array(phutil_render_tag('a', array('href' => '/file/macro/edit/' . $macro->getID() . '/'), phutil_escape_html($macro->getName())), phutil_render_tag('a', array('href' => $src, 'target' => '_blank'), phutil_render_tag('img', array('src' => $src))), javelin_render_tag('a', array('href' => '/file/macro/delete/' . $macro->getID() . '/', 'sigil' => 'workflow', 'class' => 'grey small button'), 'Delete'));
     }
     $table = new AphrontTableView($rows);
     $table->setHeaders(array('Name', 'Image', ''));
     $table->setColumnClasses(array('pri', 'wide thumb', 'action'));
     $panel = new AphrontPanelView();
     $panel->appendChild($table);
     $panel->setHeader('Image Macros');
     $panel->setCreateButton('New Image Macro', '/file/macro/edit/');
     $panel->appendChild($pager);
     return $this->buildStandardPageResponse($panel, array('title' => 'Image Macros', 'tab' => 'macros'));
 }
开发者ID:nguyennamtien,项目名称:phabricator,代码行数:28,代码来源:PhabricatorFileMacroListController.php

示例2: willBeginExecution

 public final function willBeginExecution()
 {
     $request = $this->getRequest();
     $user = new PhabricatorUser();
     $phusr = $request->getCookie('phusr');
     $phsid = $request->getCookie('phsid');
     if ($phusr && $phsid) {
         $info = queryfx_one($user->establishConnection('r'), 'SELECT u.* FROM %T u JOIN %T s ON u.phid = s.userPHID
       AND s.type LIKE %> AND s.sessionKey = %s', $user->getTableName(), 'phabricator_session', 'web-', $phsid);
         if ($info) {
             $user->loadFromArray($info);
         }
     }
     $request->setUser($user);
     if ($user->getIsDisabled() && $this->shouldRequireEnabledUser()) {
         $disabled_user_controller = newv('PhabricatorDisabledUserController', array($request));
         return $this->delegateToController($disabled_user_controller);
     }
     if (PhabricatorEnv::getEnvConfig('darkconsole.enabled')) {
         if ($user->getConsoleEnabled() || PhabricatorEnv::getEnvConfig('darkconsole.always-on')) {
             $console = new DarkConsoleCore();
             $request->getApplicationConfiguration()->setConsole($console);
         }
     }
     if ($this->shouldRequireLogin() && !$user->getPHID()) {
         $login_controller = newv('PhabricatorLoginController', array($request));
         return $this->delegateToController($login_controller);
     }
     if ($this->shouldRequireAdmin() && !$user->getIsAdmin()) {
         return new Aphront403Response();
     }
 }
开发者ID:ramons03,项目名称:phabricator,代码行数:32,代码来源:PhabricatorController.php

示例3: checkIfRepositoryIsFullyImported

 private function checkIfRepositoryIsFullyImported(PhabricatorRepository $repository)
 {
     // Check if the repository has the "Importing" flag set. We want to clear
     // the flag if we can.
     $importing = $repository->getDetail('importing');
     if (!$importing) {
         // This repository isn't marked as "Importing", so we're done.
         return;
     }
     // Look for any commit which hasn't imported.
     $unparsed_commit = queryfx_one($repository->establishConnection('r'), 'SELECT * FROM %T WHERE repositoryID = %d AND (importStatus & %d) != %d
     LIMIT 1', id(new PhabricatorRepositoryCommit())->getTableName(), $repository->getID(), PhabricatorRepositoryCommit::IMPORTED_ALL, PhabricatorRepositoryCommit::IMPORTED_ALL);
     if ($unparsed_commit) {
         // We found a commit which still needs to import, so we can't clear the
         // flag.
         return;
     }
     // Clear the "importing" flag.
     $repository->openTransaction();
     $repository->beginReadLocking();
     $repository = $repository->reload();
     $repository->setDetail('importing', false);
     $repository->save();
     $repository->endReadLocking();
     $repository->saveTransaction();
 }
开发者ID:rchicoli,项目名称:phabricator,代码行数:26,代码来源:PhabricatorRepositoryManagementUpdateWorkflow.php

示例4: doLock

 protected function doLock($wait)
 {
     $conn = $this->conn;
     if (!$conn) {
         // Try to reuse a connection from the connection pool.
         $conn = array_pop(self::$pool);
     }
     if (!$conn) {
         // NOTE: Using the 'repository' database somewhat arbitrarily, mostly
         // because the first client of locks is the repository daemons. We must
         // always use the same database for all locks, but don't access any
         // tables so we could use any valid database. We could build a
         // database-free connection instead, but that's kind of messy and we
         // might forget about it in the future if we vertically partition the
         // application.
         $dao = new PhabricatorRepository();
         // NOTE: Using "force_new" to make sure each lock is on its own
         // connection.
         $conn = $dao->establishConnection('w', $force_new = true);
         // NOTE: Since MySQL will disconnect us if we're idle for too long, we set
         // the wait_timeout to an enormous value, to allow us to hold the
         // connection open indefinitely (or, at least, for 24 days).
         $max_allowed_timeout = 2147483;
         queryfx($conn, 'SET wait_timeout = %d', $max_allowed_timeout);
     }
     $result = queryfx_one($conn, 'SELECT GET_LOCK(%s, %f)', 'phabricator:' . $this->lockname, $wait);
     $ok = head($result);
     if (!$ok) {
         throw new PhutilLockException($this->getName());
     }
     $this->conn = $conn;
 }
开发者ID:denghp,项目名称:phabricator,代码行数:32,代码来源:PhabricatorGlobalLock.php

示例5: materializeProject

 private function materializeProject(PhabricatorProject $project)
 {
     if ($project->isMilestone()) {
         return;
     }
     $material_type = PhabricatorProjectMaterializedMemberEdgeType::EDGECONST;
     $member_type = PhabricatorProjectProjectHasMemberEdgeType::EDGECONST;
     $project_phid = $project->getPHID();
     $descendants = id(new PhabricatorProjectQuery())->setViewer($this->getViewer())->withAncestorProjectPHIDs(array($project->getPHID()))->withIsMilestone(false)->withHasSubprojects(false)->execute();
     $descendant_phids = mpull($descendants, 'getPHID');
     if ($descendant_phids) {
         $source_phids = $descendant_phids;
         $has_subprojects = true;
     } else {
         $source_phids = array($project->getPHID());
         $has_subprojects = false;
     }
     $conn_w = $project->establishConnection('w');
     $any_milestone = queryfx_one($conn_w, 'SELECT id FROM %T
     WHERE parentProjectPHID = %s AND milestoneNumber IS NOT NULL
     LIMIT 1', $project->getTableName(), $project_phid);
     $has_milestones = (bool) $any_milestone;
     $project->openTransaction();
     // Delete any existing materialized member edges.
     queryfx($conn_w, 'DELETE FROM %T WHERE src = %s AND type = %s', PhabricatorEdgeConfig::TABLE_NAME_EDGE, $project_phid, $material_type);
     // Copy current member edges to create new materialized edges.
     queryfx($conn_w, 'INSERT IGNORE INTO %T (src, type, dst, dateCreated, seq)
       SELECT %s, %d, dst, dateCreated, seq FROM %T
       WHERE src IN (%Ls) AND type = %d', PhabricatorEdgeConfig::TABLE_NAME_EDGE, $project_phid, $material_type, PhabricatorEdgeConfig::TABLE_NAME_EDGE, $source_phids, $member_type);
     // Update the hasSubprojects flag.
     queryfx($conn_w, 'UPDATE %T SET hasSubprojects = %d WHERE id = %d', $project->getTableName(), (int) $has_subprojects, $project->getID());
     // Update the hasMilestones flag.
     queryfx($conn_w, 'UPDATE %T SET hasMilestones = %d WHERE id = %d', $project->getTableName(), (int) $has_milestones, $project->getID());
     $project->saveTransaction();
 }
开发者ID:truSense,项目名称:phabricator,代码行数:35,代码来源:PhabricatorProjectsMembershipIndexEngineExtension.php

示例6: getCustomTransactionNewValue

 protected function getCustomTransactionNewValue(PhabricatorLiskDAO $object, PhabricatorApplicationTransaction $xaction)
 {
     switch ($xaction->getTransactionType()) {
         case PhabricatorProjectTransaction::TYPE_NAME:
         case PhabricatorProjectTransaction::TYPE_STATUS:
         case PhabricatorProjectTransaction::TYPE_IMAGE:
         case PhabricatorProjectTransaction::TYPE_ICON:
         case PhabricatorProjectTransaction::TYPE_COLOR:
         case PhabricatorProjectTransaction::TYPE_LOCKED:
         case PhabricatorProjectTransaction::TYPE_PARENT:
             return $xaction->getNewValue();
         case PhabricatorProjectTransaction::TYPE_SLUGS:
             return $this->normalizeSlugs($xaction->getNewValue());
         case PhabricatorProjectTransaction::TYPE_MILESTONE:
             $current = queryfx_one($object->establishConnection('w'), 'SELECT MAX(milestoneNumber) n
         FROM %T
         WHERE parentProjectPHID = %s', $object->getTableName(), $object->getParentProject()->getPHID());
             if (!$current) {
                 $number = 1;
             } else {
                 $number = (int) $current['n'] + 1;
             }
             return $number;
     }
     return parent::getCustomTransactionNewValue($object, $xaction);
 }
开发者ID:phpengineer,项目名称:phabricator,代码行数:26,代码来源:PhabricatorProjectTransactionEditor.php

示例7: countUnread

 public function countUnread(PhabricatorUser $user)
 {
     $conn = $this->establishConnection('r');
     $data = queryfx_one($conn, 'SELECT COUNT(*) as count
    FROM %T
    WHERE userPHID = %s AND hasViewed = 0', $this->getTableName(), $user->getPHID());
     return $data['count'];
 }
开发者ID:barcelonascience,项目名称:phabricator,代码行数:8,代码来源:PhabricatorFeedStoryNotification.php

示例8: loadXHeraldRulesHeader

 public static function loadXHeraldRulesHeader($phid)
 {
     $header = queryfx_one(id(new HeraldTranscript())->establishConnection('r'), 'SELECT * FROM %T WHERE phid = %s', self::TABLE_SAVED_HEADER, $phid);
     if ($header) {
         return idx($header, 'header');
     }
     return null;
 }
开发者ID:nguyennamtien,项目名称:phabricator,代码行数:8,代码来源:HeraldTranscript.php

示例9: loadRandomPHID

 protected function loadRandomPHID($table)
 {
     $conn_r = $table->establishConnection('r');
     $row = queryfx_one($conn_r, 'SELECT phid FROM %T ORDER BY RAND() LIMIT 1', $table->getTableName());
     if (!$row) {
         return null;
     }
     return $row['phid'];
 }
开发者ID:AbhishekGhosh,项目名称:phabricator,代码行数:9,代码来源:PhabricatorTestDataGenerator.php

示例10: loadCommitSequence

 private function loadCommitSequence($commit_id)
 {
     $conn_r = id(new PhabricatorRepository())->establishConnection('r');
     $path_change = queryfx_one($conn_r, 'SELECT commitSequence
    FROM %T
    WHERE repositoryID = %d AND commitID = %d
    LIMIT 1', PhabricatorRepository::TABLE_PATHCHANGE, $this->request->getRepository()->getID(), $commit_id);
     return reset($path_change);
 }
开发者ID:denghp,项目名称:phabricator,代码行数:9,代码来源:DiffusionRenameHistoryQuery.php

示例11: loadRawConfigValue

 public static function loadRawConfigValue($key)
 {
     $conn_raw = id(new PhabricatorUser())->establishConnection('w');
     try {
         $value = queryfx_one($conn_raw, 'SELECT @@%Q', $key);
         $value = $value['@@' . $key];
     } catch (AphrontQueryException $ex) {
         $value = null;
     }
     return $value;
 }
开发者ID:denghp,项目名称:phabricator,代码行数:11,代码来源:PhabricatorSetupCheckMySQL.php

示例12: willBeginExecution

 public final function willBeginExecution()
 {
     $request = $this->getRequest();
     $user = new PhabricatorUser();
     $phusr = $request->getCookie('phusr');
     $phsid = $request->getCookie('phsid');
     if (strlen($phusr) && $phsid) {
         $info = queryfx_one($user->establishConnection('r'), 'SELECT u.* FROM %T u JOIN %T s ON u.phid = s.userPHID
       AND s.type LIKE %> AND s.sessionKey = %s', $user->getTableName(), 'phabricator_session', 'web-', $phsid);
         if ($info) {
             $user->loadFromArray($info);
         }
     }
     $translation = $user->getTranslation();
     if ($translation && $translation != PhabricatorEnv::getEnvConfig('translation.provider')) {
         $translation = newv($translation, array());
         PhutilTranslator::getInstance()->setLanguage($translation->getLanguage())->addTranslations($translation->getTranslations());
     }
     $request->setUser($user);
     if ($user->getIsDisabled() && $this->shouldRequireEnabledUser()) {
         $disabled_user_controller = new PhabricatorDisabledUserController($request);
         return $this->delegateToController($disabled_user_controller);
     }
     $event = new PhabricatorEvent(PhabricatorEventType::TYPE_CONTROLLER_CHECKREQUEST, array('request' => $request, 'controller' => get_class($this)));
     $event->setUser($user);
     PhutilEventEngine::dispatchEvent($event);
     $checker_controller = $event->getValue('controller');
     if ($checker_controller != get_class($this)) {
         return $this->delegateToController($checker_controller);
     }
     if (PhabricatorEnv::getEnvConfig('darkconsole.enabled')) {
         if ($user->getConsoleEnabled() || PhabricatorEnv::getEnvConfig('darkconsole.always-on')) {
             $console = new DarkConsoleCore();
             $request->getApplicationConfiguration()->setConsole($console);
         }
     }
     if ($this->shouldRequireLogin() && !$user->getPHID()) {
         $login_controller = new PhabricatorLoginController($request);
         return $this->delegateToController($login_controller);
     }
     if ($this->shouldRequireEmailVerification()) {
         $email = $user->loadPrimaryEmail();
         if (!$email) {
             throw new Exception("No primary email address associated with this account!");
         }
         if (!$email->getIsVerified()) {
             $verify_controller = new PhabricatorMustVerifyEmailController($request);
             return $this->delegateToController($verify_controller);
         }
     }
     if ($this->shouldRequireAdmin() && !$user->getIsAdmin()) {
         return new Aphront403Response();
     }
 }
开发者ID:rudimk,项目名称:phabricator,代码行数:54,代码来源:PhabricatorController.php

示例13: createComment

 protected function createComment()
 {
     $commit = $this->loadCommit();
     // TODO: Write a real PathQuery object?
     $path_id = $this->getChangesetID();
     $path = queryfx_one(id(new PhabricatorRepository())->establishConnection('r'), 'SELECT path FROM %T WHERE id = %d', PhabricatorRepository::TABLE_PATH, $path_id);
     if (!$path) {
         throw new Exception(pht('Invalid path ID!'));
     }
     return id(new PhabricatorAuditInlineComment())->setCommitPHID($commit->getPHID())->setPathID($path_id);
 }
开发者ID:pugong,项目名称:phabricator,代码行数:11,代码来源:DiffusionInlineCommentController.php

示例14: processRequest

 public function processRequest()
 {
     $request = $this->getRequest();
     $viewer = $request->getUser();
     $is_admin = $viewer->getIsAdmin();
     $user = new PhabricatorUser();
     $count = queryfx_one($user->establishConnection('r'), 'SELECT COUNT(*) N FROM %T', $user->getTableName());
     $count = idx($count, 'N', 0);
     $pager = new AphrontPagerView();
     $pager->setOffset($request->getInt('page', 0));
     $pager->setCount($count);
     $pager->setURI($request->getRequestURI(), 'page');
     $users = id(new PhabricatorPeopleQuery())->needPrimaryEmail(true)->executeWithOffsetPager($pager);
     $rows = array();
     foreach ($users as $user) {
         $primary_email = $user->loadPrimaryEmail();
         if ($primary_email && $primary_email->getIsVerified()) {
             $email = 'Verified';
         } else {
             $email = 'Unverified';
         }
         $status = array();
         if ($user->getIsDisabled()) {
             $status[] = 'Disabled';
         }
         if ($user->getIsAdmin()) {
             $status[] = 'Admin';
         }
         if ($user->getIsSystemAgent()) {
             $status[] = 'System Agent';
         }
         $status = implode(', ', $status);
         $rows[] = array(phabricator_date($user->getDateCreated(), $viewer), phabricator_time($user->getDateCreated(), $viewer), phutil_render_tag('a', array('href' => '/p/' . $user->getUsername() . '/'), phutil_escape_html($user->getUserName())), phutil_escape_html($user->getRealName()), $status, $email, phutil_render_tag('a', array('class' => 'button grey small', 'href' => '/people/edit/' . $user->getID() . '/'), 'Administrate User'));
     }
     $table = new AphrontTableView($rows);
     $table->setHeaders(array('Join Date', 'Time', 'Username', 'Real Name', 'Roles', 'Email', ''));
     $table->setColumnClasses(array(null, 'right', 'pri', 'wide', null, null, 'action'));
     $table->setColumnVisibility(array(true, true, true, true, $is_admin, $is_admin, $is_admin));
     $panel = new AphrontPanelView();
     $panel->setHeader('People (' . number_format($count) . ')');
     $panel->appendChild($table);
     $panel->appendChild($pager);
     if ($is_admin) {
         $panel->addButton(phutil_render_tag('a', array('href' => '/people/edit/', 'class' => 'button green'), 'Create New Account'));
         if (PhabricatorEnv::getEnvConfig('ldap.auth-enabled')) {
             $panel->addButton(phutil_render_tag('a', array('href' => '/people/ldap/', 'class' => 'button green'), 'Import from LDAP'));
         }
     }
     $nav = $this->buildSideNavView();
     $nav->selectFilter('people');
     $nav->appendChild($panel);
     return $this->buildApplicationPage($nav, array('title' => 'People'));
 }
开发者ID:neoxen,项目名称:phabricator,代码行数:53,代码来源:PhabricatorPeopleListController.php

示例15: processRequest

 public function processRequest()
 {
     $request = $this->getRequest();
     $macro_table = new PhabricatorFileImageMacro();
     if ($request->getStr('name') !== null) {
         $macros = $macro_table->loadAllWhere('name LIKE %~', $request->getStr('name'));
     } else {
         $pager = new AphrontPagerView();
         $pager->setOffset($request->getInt('page'));
         $macros = $macro_table->loadAllWhere('1 = 1 ORDER BY id DESC LIMIT %d, %d', $pager->getOffset(), $pager->getPageSize());
         // Get an exact count since the size here is reasonably going to be a few
         // thousand at most in any reasonable case.
         $count = queryfx_one($macro_table->establishConnection('r'), 'SELECT COUNT(*) N FROM %T', $macro_table->getTableName());
         $count = $count['N'];
         $pager->setCount($count);
         $pager->setURI($request->getRequestURI(), 'page');
     }
     $file_phids = mpull($macros, 'getFilePHID');
     $files = array();
     if ($file_phids) {
         $files = id(new PhabricatorFile())->loadAllWhere("phid IN (%Ls)", $file_phids);
         $author_phids = mpull($files, 'getAuthorPHID', 'getPHID');
         $handles = id(new PhabricatorObjectHandleData($author_phids))->loadHandles();
     }
     $files_map = mpull($files, null, 'getPHID');
     $rows = array();
     foreach ($macros as $macro) {
         $file_phid = $macro->getFilePHID();
         $file = idx($files_map, $file_phid);
         $author_link = isset($author_phids[$file_phid]) ? $handles[$author_phids[$file_phid]]->renderLink() : null;
         $rows[] = array(phutil_render_tag('a', array('href' => '/file/macro/edit/' . $macro->getID() . '/'), phutil_escape_html($macro->getName())), $author_link, phutil_render_tag('a', array('href' => $file ? $file->getBestURI() : null, 'target' => '_blank'), phutil_render_tag('img', array('src' => $file ? $file->getBestURI() : null))), javelin_render_tag('a', array('href' => '/file/macro/delete/' . $macro->getID() . '/', 'sigil' => 'workflow', 'class' => 'grey small button'), 'Delete'));
     }
     $table = new AphrontTableView($rows);
     $table->setHeaders(array('Name', 'Author', 'Image', ''));
     $table->setColumnClasses(array('pri', '', 'wide thumb', 'action'));
     $filter_form = id(new AphrontFormView())->setMethod('GET')->setAction('/file/macro/')->setUser($request->getUser())->appendChild(id(new AphrontFormTextControl())->setName('name')->setLabel('Name')->setValue($request->getStr('name')))->appendChild(id(new AphrontFormSubmitControl())->setValue('Filter Image Macros'));
     $filter_view = new AphrontListFilterView();
     $filter_view->appendChild($filter_form);
     $filter_view->addButton(phutil_render_tag('a', array('href' => '/file/macro/edit/', 'class' => 'green button'), 'New Image Macro'));
     $panel = new AphrontPanelView();
     $panel->appendChild($table);
     $panel->setHeader('Image Macros');
     if ($request->getStr('name') === null) {
         $panel->appendChild($pager);
     }
     $side_nav = new PhabricatorFileSideNavView();
     $side_nav->setSelectedFilter('all_macros');
     $side_nav->appendChild($filter_view);
     $side_nav->appendChild($panel);
     return $this->buildStandardPageResponse($side_nav, array('title' => 'Image Macros'));
 }
开发者ID:neoxen,项目名称:phabricator,代码行数:51,代码来源:PhabricatorFileMacroListController.php


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