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


PHP Zend_Db_Adapter_Abstract::fetchOne方法代码示例

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


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

示例1: processTokenData

 /**
  * Process the data and return the answers that should be changed.
  *
  * Storing the changed values is handled by the calling function.
  *
  * @param \Gems_Tracker_Token $token Gems token object
  * @return array Containing the changed values
  */
 public function processTokenData(\Gems_Tracker_Token $token)
 {
     if (!$token->getReceptionCode()->isSuccess()) {
         return;
     }
     $answers = $token->getRawAnswers();
     if (isset($answers['informedconsent'])) {
         $consent = $this->util->getConsent($answers['informedconsent']);
         if ($consent->exists) {
             // Is existing consent description as answer
             $consentCode = $consent->getDescription();
         } else {
             if ($answers['informedconsent']) {
                 // Uses start of consent description as answer (LS has only 5 chars for an answer option)
                 $consentCode = $this->db->fetchOne("SELECT gco_description FROM gems__consents WHERE gco_description LIKE ? ORDER BY gco_order", $answers['informedconsent'] . '%');
             } else {
                 $consentCode = false;
             }
             if (!$consentCode) {
                 if ($answers['informedconsent']) {
                     // Code not found, use first positive consent
                     $consentCode = $this->db->fetchOne("SELECT gco_description FROM gems__consents WHERE gco_code != ? ORDER BY gco_order", $this->util->getConsentRejected());
                 } else {
                     // Code not found, use first negative consent
                     $consentCode = $this->db->fetchOne("SELECT gco_description FROM gems__consents WHERE gco_code = ? ORDER BY gco_order", $this->util->getConsentRejected());
                 }
             }
         }
         $respondent = $token->getRespondent();
         $values = array('gr2o_patient_nr' => $respondent->getPatientNumber(), 'gr2o_id_organization' => $respondent->getOrganizationId(), 'gr2o_consent' => $consentCode);
         $respondent->getRespondentModel()->save($values);
     }
     return false;
 }
开发者ID:GemsTracker,项目名称:gemstracker-library,代码行数:42,代码来源:SetInformedConsent.php

示例2: execute

 /**
  * Should handle execution of the task, taking as much (optional) parameters as needed
  *
  * The parameters should be optional and failing to provide them should be handled by
  * the task
  */
 public function execute($lineNr = null, $organizationData = null)
 {
     $batch = $this->getBatch();
     $import = $batch->getVariable('import');
     if (isset($organizationData['gor_id_organization']) && $organizationData['gor_id_organization']) {
         $oldId = $organizationData['gor_id_organization'];
     } else {
         $oldId = false;
         $batch->addToCounter('import_errors');
         $batch->addMessage(sprintf($this->_('No gor_id_organization not specified for organization at line %d.'), $lineNr));
     }
     if (isset($organizationData['gor_name']) && $organizationData['gor_name']) {
         if ($oldId) {
             $orgId = $this->db->fetchOne("SELECT gor_id_organization FROM gems__organizations WHERE gor_name = ?", $organizationData['gor_name']);
             if ($orgId) {
                 $import['organizationIds'][$oldId] = $orgId;
                 $import['formDefaults']['gtr_organizations'][] = $orgId;
             } else {
                 $import['organizationIds'][$oldId] = false;
             }
         }
     } else {
         $orgId = false;
         $batch->addToCounter('import_errors');
         $batch->addMessage(sprintf($this->_('No gor_name not specified for organization at line %d.'), $lineNr));
     }
 }
开发者ID:harmslijper,项目名称:gemstracker-library,代码行数:33,代码来源:CheckTrackOrganizationImportTask.php

示例3: execute

 /**
  * Should handle execution of the task, taking as much (optional) parameters as needed
  *
  * The parameters should be optional and failing to provide them should be handled by
  * the task
  *
  * @param array $row Row to save
  */
 public function execute($row = null)
 {
     if ($row) {
         if (!isset($row['grs_id_user']) && isset($row['grs_ssn']) && $this->targetModel instanceof \Gems_Model_RespondentModel && $this->targetModel->hashSsn !== \Gems_Model_RespondentModel::SSN_HIDE) {
             if (\Gems_Model_RespondentModel::SSN_HASH === $this->targetModel->hashSsn) {
                 $search = $this->targetModel->saveSSN($row['grs_ssn']);
             } else {
                 $search = $row['grs_ssn'];
             }
             $sql = 'SELECT grs_id_user FROM gems__respondents WHERE grs_ssn = ?';
             $id = $this->db->fetchOne($sql, $search);
             // Check for change in patient ID
             if ($id) {
                 if (isset($row['gr2o_id_organization']) && $this->targetModel instanceof \MUtil_Model_DatabaseModelAbstract) {
                     $sql = 'SELECT gr2o_patient_nr
                             FROM gems__respondent2org
                             WHERE gr2o_id_user = ? AND gr2o_id_organization = ?';
                     $patientId = $this->db->fetchOne($sql, array($id, $row['gr2o_id_organization']));
                     if ($patientId) {
                         // Change the patient number
                         $copyId = $this->targetModel->getKeyCopyName('gr2o_patient_nr');
                         $row[$copyId] = $patientId;
                     }
                 }
                 $row['grs_id_user'] = $id;
                 $row['gr2o_id_user'] = $id;
             }
         }
         parent::execute($row);
     }
 }
开发者ID:harmslijper,项目名称:gemstracker-library,代码行数:39,代码来源:SaveRespondentTask.php

示例4: getCurrentSchemaVersion

 public function getCurrentSchemaVersion()
 {
     if (empty($this->_module)) {
         throw new FFR_Exception('Module was empty.  A module must be set.');
     }
     $cache = Zend_Controller_Action_HelperBroker::getStaticHelper('Cache')->getManager()->getCache('database');
     if (!($version = $cache->load($this->_module . 'Version'))) {
         // Ensure we have valid connection to the database
         if (!$this->_db->isConnected()) {
             $this->_db->getServerVersion();
         }
         $sql = 'SELECT schema_version FROM ' . $this->_schemaVersionTable . ' WHERE schema_module = "' . $this->_module . '"';
         $version = null;
         try {
             $version = $this->_db->fetchOne($sql);
         } catch (Zend_Db_Exception $e) {
             // exception means that the schema version table doesn't exist, so create it
             $createSql = "CREATE TABLE {$this->_schemaVersionTable} (\n                                schema_id INT NOT NULL AUTO_INCREMENT,\n                                schema_version INT NOT NULL,\n                                schema_module VARCHAR(50),\n                                PRIMARY KEY (schema_id)\n                            )";
             $this->_db->query($createSql);
         }
         // There isn't a version record so lets make one
         if ($version === null || $version === false) {
             $insertSql = "INSERT  {$this->_schemaVersionTable} SET schema_version = 0," . ' schema_module = "' . $this->_module . '"';
             $this->_db->query($insertSql);
             $version = $this->_db->fetchOne($sql);
         }
         $cache->save($version, $this->_module . 'Version', array('schemaVersion'));
     }
     return $version;
 }
开发者ID:rantoine,项目名称:AdvisorIllustrator,代码行数:30,代码来源:Manager.php

示例5: getById

    /**
     * Fetches a single order by its unique Id.
     *
     * @param  int $id
     * @return Order
     */
    public function getById($id)
    {
        try {
            $result = $this->_database->fetchOne(
                'SELECT o.*,c.* FROM order o INNER JOIN customer c ON o.customer_id = c.id WHERE o.id = ?',
                array($id));

            if ($result == null) throw new \Exception("Could not find order with id " . $id);
            $customer = new Customer();
            $customer->setName($result['name']);
            $customer->setAddress1($result['address_1']);
            $customer->setAddress2($result['address_2']);
            $customer->setCity($result['city']);
            $customer->setState($result['state']);
            $customer->setPostalCode($result['postal_code']);
            $customer->setCellphone($result['cell_phone']);
            $customer->setEmail($result['email']);
            $customer->setCallbackUrl($result['callback_url']);
            $order = new Order();
            $order->setId($id);
            $order->setCustomer($customer);

            return $order;
        }
        catch (\Exception $e)
        {
            throw $e;
        }
    }
开发者ID:neraath,项目名称:ioc-php-talk,代码行数:35,代码来源:OrderRepository.php

示例6: configure

    public function configure(XenForo_ControllerAdmin_Abstract $controller, array &$config)
    {
        if ($config) {
            $errors = $this->validateConfiguration($config, $validatedDirectories);
            if ($errors) {
                return $controller->responseError($errors);
            } else {
                if (!isset($config['attachmentPaths'])) {
                    $attachPaths = $this->_sourceDb->fetchOne('
					SELECT value
					FROM ' . $this->_prefix . 'settings
					WHERE variable = \'attachmentUploadDir\'
				');
                    $path = @unserialize($attachPaths);
                    if (!$path) {
                        if ($attachPaths) {
                            $path = array($attachPaths);
                        } else {
                            $path = array('');
                        }
                    }
                    $viewParams = array('attachPaths' => $path ? $path : array(), 'config' => $config);
                    return $controller->responseView('XenForo_ViewAdmin_Import_SMF_Config_Attachments', 'import_smf_config_attachments', $viewParams);
                }
            }
            if ($validatedDirectories) {
                return true;
            }
        } else {
            $viewParams = array();
        }
        return $controller->responseView('XenForo_ViewAdmin_Import_SMF_Config', 'import_smf_config', $viewParams);
    }
开发者ID:namgiangle90,项目名称:tokyobaito,代码行数:33,代码来源:SMF.php

示例7: getPaidAmount

 /**
  * Get the total paid amount by this customer.
  * Replaces: calc_customer_paid()
  * Enter description here ...
  */
 public function getPaidAmount()
 {
     $tbl_prefix = SimpleInvoices_Db_Table_Abstract::getTablePrefix();
     $select = new Zend_Db_Select($this->_db);
     $select->from($tbl_prefix . "payment", array('amount' => new Zend_Db_Expr("COALESCE(SUM(" . $tbl_prefix . "payment.ac_amount), 0)")));
     $select->joinInner($tbl_prefix . "invoices", $tbl_prefix . "payment.ac_inv_id=" . $tbl_prefix . "invoices.id", NULL);
     $select->where($tbl_prefix . "invoices.customer_id=?", $this->_id);
     return $this->_db->fetchOne($select);
 }
开发者ID:CalhounGaming,项目名称:simpleinvoices,代码行数:14,代码来源:Customer.php

示例8: getSchemaVersion

 /**
  * Fetch the schema version of the current database
  *
  * @return string
  */
 public final function getSchemaVersion()
 {
     if (!in_array('schema_info', $this->dbAdapter->listTables())) {
         $this->createTable('schema_info', array('primary' => false), array(array('version', 'string')));
         $this->dbAdapter->insert('schema_info', array('version' => '00000000000000'));
         return '00000000000000';
     }
     return $this->dbAdapter->fetchOne($this->dbAdapter->select()->from('schema_info', 'version')->limit(1));
 }
开发者ID:humansky,项目名称:qframe,代码行数:14,代码来源:Adapter.php

示例9: updateQueryTable

 /**
  * @param $oo_id
  * @param $ids
  * @param $fieldname
  * @throws \Zend_Db_Adapter_Exception
  */
 protected function updateQueryTable($oo_id, $ids, $fieldname)
 {
     if (!empty($ids)) {
         $value = $this->db->fetchOne("SELECT `{$fieldname}` FROM " . $this->querytable . " WHERE " . $this->idField . " = ?", $oo_id);
         $this->db->update($this->querytable, [$fieldname => $value], $this->idField . " IN (" . implode(",", $ids) . ")");
     }
 }
开发者ID:solverat,项目名称:pimcore,代码行数:13,代码来源:InheritanceHelper.php

示例10: getPaginator

 /**
  * Возвращает массив опций для построения постраничной навигации
  * Необходимо дергать сразу после выполнения SQL-запроса с SQL_CAL_FOUND_ROWS
  * 
  * @param array $options - Массив опций
  * 
  * @return object
  */
 function getPaginator($options = array())
 {
     $Paginator = new Zend_Paginator(new Zend_Paginator_Adapter_Null($this->_db->fetchOne('SELECT FOUND_ROWS()')));
     $Paginator->setItemCountPerPage(isset($options['perpage']) ? $options['perpage'] : $this->getPerPage());
     if (isset($options['widgetid'])) {
         $Paginator->setCurrentPageNumber($this->getCurrentPage($options['widgetid']));
     } else {
         $Paginator->setCurrentPageNumber($this->getCurrentPage());
     }
     $out = $Paginator->getPages();
     $pageidentity = $this->getPageIdentity();
     // Кроме стандартных параметров Zend_Paginator::getPages() возвращаем доп. параметры
     // Полный путь без GET-запроса
     $UrlInfo = parse_url($this->_request->getRequestUri());
     $out->ClearUrl = $UrlInfo['path'];
     // Обрабатываем GET-запрос
     $query = $this->_request->getQuery();
     if (isset($query[$pageidentity])) {
         unset($query[$pageidentity]);
     }
     if (isset($query['widget'])) {
         unset($query['widget']);
     }
     // Строим строку выражения
     if (!empty($query)) {
         $out->Query = http_build_query($query);
     }
     // Фактически, ссылку на первую страницу (без page и widget)
     $out->FullUrl = isset($out->Query) ? $out->ClearUrl . '?' . $out->Query : $out->ClearUrl;
     // Добавляем к выражению Id виджета
     $widget = isset($options['widgetid']) ? 'widget=' . (int) $options['widgetid'] . '&' : '';
     // Полную ссылку к которой в конце надо только добавить номер страницы
     $out->PageUrl = isset($out->Query) ? $out->FullUrl . '&' . $widget . $pageidentity . '=' : $out->FullUrl . '?' . $widget . $pageidentity . '=';
     return $out;
 }
开发者ID:ei-grad,项目名称:phorm,代码行数:43,代码来源:Model.php

示例11: testAdapterFetchOne

 /**
  * Test the Adapter's fetchOne() method.
  */
 public function testAdapterFetchOne()
 {
     $table = $this->getIdentifier(self::TABLE_NAME);
     $title = 'News Item 1';
     $result = $this->_db->fetchOne('SELECT title FROM ' . $this->_db->quoteIdentifier($table) . ' WHERE date_created > ? ORDER BY id', array('2006-01-01'));
     $this->assertEquals($title, $result);
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:10,代码来源:Common.php

示例12: executeAction

 /**
  * Execute a single mail job
  */
 public function executeAction()
 {
     $jobId = $this->getParam(\MUtil_Model::REQUEST_ID);
     $batch = $this->loader->getTaskRunnerBatch('commjob-execute-' . $jobId);
     $batch->minimalStepDurationMs = 3000;
     // 3 seconds max before sending feedback
     if (!$batch->isLoaded() && !is_null($jobId)) {
         // Check for unprocessed tokens
         $tracker = $this->loader->getTracker();
         $tracker->processCompletedTokens(null, $this->currentUser->getUserId());
         // We could skip this, but a check before starting the batch is better
         $sql = $this->db->select()->from('gems__comm_jobs', array('gcj_id_job'))->where('gcj_active = 1')->where('gcj_id_job = ?', $jobId);
         $job = $this->db->fetchOne($sql);
         if (!empty($job)) {
             $batch->addTask('Mail\\ExecuteMailJobTask', $job);
         }
     }
     if ($batch->isFinished()) {
         // Add the messages to the view and forward
         $messages = $batch->getMessages(true);
         foreach ($messages as $message) {
             $this->addMessage($message);
         }
         $this->_reroute(array('action' => 'show'));
     }
     $this->_helper->BatchRunner($batch, $this->_('Execute single mail job'), $this->accesslog);
 }
开发者ID:GemsTracker,项目名称:gemstracker-library,代码行数:30,代码来源:CommJobAction.php

示例13: _insertFields

 /**
  *
  * @param array $inserts
  */
 protected function _insertFields(array $inserts)
 {
     foreach ($inserts as $insert) {
         if (isset($insert['table_name'], $insert['data_writer'])) {
             $dw = XenForo_DataWriter::create($insert['data_writer']);
             if (isset($insert['primary_fields'])) {
                 $sql = "SELECT count(*) FROM `" . $insert['table_name'] . "` ";
                 $whereClauses = array();
                 foreach ($insert['primary_fields'] as $fieldName => $fieldValue) {
                     $whereClauses[] = "`" . $fieldName . "` = '" . $fieldValue . "'";
                 }
                 if (!empty($whereClauses)) {
                     $sql .= "WHERE " . implode(" AND ", $whereClauses) . " ";
                 }
                 if ($this->_db->fetchOne($sql)) {
                     $dw->setExistingData($insert['primary_fields']);
                 }
             }
             $dw->bulkSet($insert['primary_fields']);
             if (isset($insert['fields'])) {
                 $dw->bulkSet($insert['fields']);
             }
             $dw->save();
         }
     }
 }
开发者ID:Sywooch,项目名称:forums,代码行数:30,代码来源:20150107.php

示例14: getCount

 public function getCount($condition, $orderBy = null, $limit = null, $offset = null)
 {
     if ($condition) {
         $condition = "WHERE " . $condition;
     }
     if ($orderBy) {
         $orderBy = " ORDER BY " . $orderBy;
     }
     if ($limit) {
         if ($offset) {
             $limit = "LIMIT " . $offset . ", " . $limit;
         } else {
             $limit = "LIMIT " . $limit;
         }
     }
     if ($this->model->getVariantMode() == OnlineShop_Framework_IProductList::VARIANT_MODE_INCLUDE_PARENT_OBJECT) {
         $query = "SELECT count(DISTINCT o_virtualProductId) FROM " . $this->model->getCurrentTenantConfig()->getTablename() . " a " . $this->model->getCurrentTenantConfig()->getJoins() . $condition . $orderBy . " " . $limit;
     } else {
         $query = "SELECT count(*) FROM " . $this->model->getCurrentTenantConfig()->getTablename() . " a " . $this->model->getCurrentTenantConfig()->getJoins() . $condition . $orderBy . " " . $limit;
     }
     OnlineShop_Plugin::getSQLLogger()->log("Query: " . $query, Zend_Log::INFO);
     $result = $this->db->fetchOne($query);
     OnlineShop_Plugin::getSQLLogger()->log("Query done.", Zend_Log::INFO);
     return $result;
 }
开发者ID:ascertain,项目名称:NGshop,代码行数:25,代码来源:Resource.php

示例15: move

 /**
  * Move tree node
  *
  * @todo Use adapter for generate conditions
  * @param Varien_Data_Tree_Node $node
  * @param Varien_Data_Tree_Node $newParent
  * @param Varien_Data_Tree_Node $prevNode
  */
 public function move($node, $newParent, $prevNode = null)
 {
     $position = 1;
     $oldPath = $node->getData($this->_pathField);
     $newPath = $newParent->getData($this->_pathField);
     $newPath = $newPath . '/' . $node->getId();
     $oldPathLength = strlen($oldPath);
     $newLevel = $newParent->getLevel() + 1;
     $levelDisposition = $newLevel - $node->getLevel();
     $data = array($this->_levelField => new Zend_Db_Expr("{$this->_levelField} + '{$levelDisposition}'"), $this->_pathField => new Zend_Db_Expr("CONCAT('{$newPath}', RIGHT({$this->_pathField}, LENGTH({$this->_pathField}) - {$oldPathLength}))"));
     $condition = $this->_conn->quoteInto("{$this->_pathField} REGEXP ?", "^{$oldPath}(/|\$)");
     $this->_conn->beginTransaction();
     $reorderData = array($this->_orderField => new Zend_Db_Expr("{$this->_orderField} + 1"));
     try {
         if ($prevNode && $prevNode->getId()) {
             $reorderCondition = "{$this->_orderField} > {$prevNode->getData($this->_orderField)}";
             $position = $prevNode->getData($this->_orderField) + 1;
         } else {
             $reorderCondition = $this->_conn->quoteInto("{$this->_pathField} REGEXP ?", "^{$newParent->getData($this->_pathField)}/[0-9]+\$");
             $select = $this->_conn->select()->from($this->_table, new Zend_Db_Expr("MIN({$this->_orderField})"))->where($reorderCondition);
             $position = (int) $this->_conn->fetchOne($select);
         }
         $this->_conn->update($this->_table, $reorderData, $reorderCondition);
         $this->_conn->update($this->_table, $data, $condition);
         $this->_conn->update($this->_table, array($this->_orderField => $position, $this->_levelField => $newLevel), $this->_conn->quoteInto("{$this->_idField} = ?", $node->getId()));
         $this->_conn->commit();
     } catch (Exception $e) {
         $this->_conn->rollBack();
         throw new Exception("Can't move tree node due to error: " . $e->getMessage());
     }
 }
开发者ID:barneydesmond,项目名称:propitious-octo-tribble,代码行数:39,代码来源:Dbp.php


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