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


PHP Zend_Db_Adapter_Abstract::fetchRow方法代码示例

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


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

示例1: loadByName

 public function loadByName(Mage_Directory_Model_Region $region, $regionName, $countryId)
 {
     $locale = Mage::app()->getLocale()->getLocaleCode();
     $select = $this->_read->select()->from(array('region' => $this->_regionTable))->where('region.country_id=?', $countryId)->where('region.default_name=?', $regionName)->join(array('rname' => $this->_regionNameTable), 'rname.region_id=region.region_id AND rname.locale=\'' . $locale . '\'', array('name'));
     $region->setData($this->_read->fetchRow($select));
     return $this;
 }
开发者ID:arslbbt,项目名称:mangentovies,代码行数:7,代码来源:Region.php

示例2: getTableDataDump

 public function getTableDataDump($tableName, $step = 100)
 {
     $sql = '';
     if ($this->_read) {
         $quotedTableName = $this->_read->quoteIdentifier($tableName);
         $colunms = $this->_read->fetchRow('SELECT * FROM ' . $quotedTableName . ' LIMIT 1');
         if ($colunms) {
             $arrSql = array();
             $colunms = array_keys($colunms);
             $quote = $this->_read->getQuoteIdentifierSymbol();
             $sql = 'INSERT INTO ' . $quotedTableName . ' (' . $quote . implode($quote . ', ' . $quote, $colunms) . $quote . ')';
             $sql .= ' VALUES ';
             $startRow = 0;
             $select = $this->_read->select();
             $select->from($tableName)->limit($step, $startRow);
             while ($data = $this->_read->fetchAll($select)) {
                 $dataSql = array();
                 foreach ($data as $row) {
                     $dataSql[] = $this->_read->quoteInto('(?)', $row);
                 }
                 $arrSql[] = $sql . implode(', ', $dataSql) . ';';
                 $startRow += $step;
                 $select->limit($step, $startRow);
             }
             $sql = implode("\n", $arrSql) . "\n";
         }
     }
     return $sql;
 }
开发者ID:arslbbt,项目名称:mangentovies,代码行数:29,代码来源:Db.php

示例3: load

 public function load($roleId)
 {
     if ($roleId) {
         $row = $this->_read->fetchRow("SELECT * FROM {$this->_roleTable} WHERE role_id = {$roleId}");
         return $row;
     } else {
         return array();
     }
 }
开发者ID:arslbbt,项目名称:mangentovies,代码行数:9,代码来源:Roles.php

示例4: _initData

 /**
  * Initialize payment data.
  * replaces method getPayment($id)
  */
 protected function _initData()
 {
     $tbl_prefix = SimpleInvoices_Db_Table_Abstract::getTablePrefix();
     $select = new Zend_Db_Select($this->_db);
     $select->from($tbl_prefix . 'payment');
     $select->joinInner($tbl_prefix . 'invoices', $tbl_prefix . "payment.ac_inv_id = " . $tbl_prefix . "invoices.id", NULL);
     $select->joinInner($tbl_prefix . 'customers', $tbl_prefix . "invoices.customer_id = " . $tbl_prefix . "customers.id", array('customer_id' => $tbl_prefix . "customers.id", 'customer' => $tbl_prefix . "customers.name"));
     $select->joinInner($tbl_prefix . 'biller', $tbl_prefix . "invoices.biller_id = " . $tbl_prefix . "biller.id", array('biller_id' => $tbl_prefix . "biller.id", 'biller' => $tbl_prefix . "biller.name"));
     $select->where($tbl_prefix . 'payment.id=?', $this->_id);
     $this->_data = $this->_db->fetchRow($select);
     $this->_data['date'] = siLocal::date($payment['ac_date']);
 }
开发者ID:CalhounGaming,项目名称:simpleinvoices,代码行数:16,代码来源:Payment.php

示例5: get

 /**
  * read syncstate from database 
  *
  * @param ActiceSync_Model_SyncState $_syncState
  * @return ActiceSync_Model_SyncState
  */
 public function get(ActiveSync_Model_SyncState $_syncState)
 {
     $select = $this->_db->select()->from(SQL_TABLE_PREFIX . 'acsync_synckey')->where('device_id = ?', $_syncState->device_id)->where('type = ?', $_syncState->type)->order('counter DESC')->limit(1);
     if (!empty($_syncState->counter)) {
         $select->where('counter = ?', $_syncState->counter);
     }
     $row = $this->_db->fetchRow($select);
     if (!$row) {
         throw new ActiveSync_Exception_SyncStateNotFound('syncState not found: ' . $select);
     }
     $result = new ActiveSync_Model_SyncState($row);
     return $result;
 }
开发者ID:rodrigofns,项目名称:ExpressoLivre3,代码行数:19,代码来源:SyncState.php

示例6: calculateFieldInfo

 /**
  * Calculation the field info display for this type
  *
  * @param array $currentValue The current value
  * @param array $fieldData The other values loaded so far
  * @return mixed the new value
  */
 public function calculateFieldInfo($currentValue, array $fieldData)
 {
     if (!$currentValue) {
         return $currentValue;
     }
     // Display nice
     $sql = $this->_sql . "WHERE grr_id = ?";
     $row = $this->db->fetchRow($sql, $currentValue);
     if ($row && isset($row['name'])) {
         return $row['name'];
     }
     return $currentValue;
 }
开发者ID:GemsTracker,项目名称:gemstracker-library,代码行数:20,代码来源:RelationField.php

示例7: aggregate

 public function aggregate($object)
 {
     if (!$object->getEntityPkValue() && $object->getId()) {
         $object->load($object->getReviewId());
     }
     $ratingModel = Mage::getModel('rating/rating');
     $ratingSummaries = $ratingModel->getEntitySummary($object->getEntityPkValue(), false);
     $nonDelete = array();
     foreach ($ratingSummaries as $ratingSummaryObject) {
         if ($ratingSummaryObject->getCount()) {
             $ratingSummary = round($ratingSummaryObject->getSum() / $ratingSummaryObject->getCount());
         } else {
             $ratingSummary = $ratingSummaryObject->getSum();
         }
         $reviewsCount = $this->getTotalReviews($object->getEntityPkValue(), true, $ratingSummaryObject->getStoreId());
         $select = $this->_read->select();
         $select->from($this->_aggregateTable)->where("{$this->_aggregateTable}.entity_pk_value = ?", $object->getEntityPkValue())->where("{$this->_aggregateTable}.entity_type = ?", $object->getEntityId())->where("{$this->_aggregateTable}.store_id = ?", $ratingSummaryObject->getStoreId());
         $oldData = $this->_read->fetchRow($select);
         $data = new Varien_Object();
         $data->setReviewsCount($reviewsCount)->setEntityPkValue($object->getEntityPkValue())->setEntityType($object->getEntityId())->setRatingSummary($ratingSummary > 0 ? $ratingSummary : 0)->setStoreId($ratingSummaryObject->getStoreId());
         $this->_write->beginTransaction();
         try {
             if ($oldData['primary_id'] > 0) {
                 $condition = $this->_write->quoteInto("{$this->_aggregateTable}.primary_id = ?", $oldData['primary_id']);
                 $this->_write->update($this->_aggregateTable, $data->getData(), $condition);
             } else {
                 $this->_write->insert($this->_aggregateTable, $data->getData());
             }
             $this->_write->commit();
         } catch (Exception $e) {
             $this->_write->rollBack();
         }
     }
 }
开发者ID:arslbbt,项目名称:mangentovies,代码行数:34,代码来源:Review.php

示例8: getHeader

 /**
  * Returns SQL header data
  */
 public function getHeader()
 {
     $dbConfig = $this->_read->getConfig();
     $versionRow = $this->_read->fetchRow('SHOW VARIABLES LIKE \'version\'');
     $header = "-- Magento DB backup\n" . "--\n" . "-- Host: {$dbConfig['host']}    Database: {$dbConfig['dbname']}\n" . "-- ------------------------------------------------------\n" . "-- Server version: {$versionRow['Value']}\n\n" . "/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;\n" . "/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;\n" . "/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;\n" . "/*!40101 SET NAMES utf8 */;\n" . "/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;\n" . "/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;\n" . "/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;\n" . "/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;\n";
     return $header;
 }
开发者ID:ronseigel,项目名称:agent-ohm,代码行数:10,代码来源:Mysql4_Db.php

示例9: load

 public function load($object, $customerId)
 {
     $select = $this->_read->select();
     $select->from($this->_customerTable, array('login_at', 'logout_at'))->joinInner($this->_visitorTable, $this->_visitorTable . '.visitor_id=' . $this->_customerTable . '.visitor_id', array('last_visit_at'))->joinInner($this->_visitorInfoTable, $this->_visitorTable . '.visitor_id=' . $this->_visitorInfoTable . '.visitor_id', array('http_referer', 'remote_addr'))->joinInner($this->_urlInfoTable, $this->_urlInfoTable . '.url_id=' . $this->_visitorTable . '.last_url_id', array('url'))->where($this->_read->quoteInto($this->_customerTable . '.customer_id=?', $customerId))->order($this->_customerTable . '.login_at desc')->limit(1);
     $object->setData($this->_read->fetchRow($select));
     return $object;
 }
开发者ID:ronseigel,项目名称:agent-ohm,代码行数:7,代码来源:Mysql4_Customer.php

示例10: isValid

 /**
  * Returns true if and only if $value meets the validation requirements
  *
  * If $value fails validation, then this method returns false, and
  * getMessages() will return an array of messages that explain why the
  * validation failed.
  *
  * @param  mixed $value
  * @return boolean
  * @throws \Zend_Valid_Exception If validation of $value is impossible
  */
 public function isValid($value)
 {
     if ($throttleSettings = $this->project->getAskThrottleSettings()) {
         // Prune the database for (very) old attempts
         $where = $this->db->quoteInto('gta_datetime < DATE_SUB(NOW(), INTERVAL ? second)', $throttleSettings['period'] * 20);
         $this->db->delete('gems__token_attempts', $where);
         // Retrieve the number of failed attempts that occurred within the specified window
         $select = $this->db->select();
         $select->from('gems__token_attempts', array(new \Zend_Db_Expr('COUNT(*) AS attempts'), new \Zend_Db_Expr('UNIX_TIMESTAMP(MAX(gta_datetime)) - UNIX_TIMESTAMP() AS last')))->where('gta_datetime > DATE_SUB(NOW(), INTERVAL ? second)', $throttleSettings['period']);
         $attemptData = $this->db->fetchRow($select);
         $remainingDelay = $attemptData['last'] + $throttleSettings['delay'];
         // \MUtil_Echo::track($throttleSettings, $attemptData, $remainingDelay);
         if ($attemptData['attempts'] > $throttleSettings['threshold'] && $remainingDelay > 0) {
             $this->logger->log("Possible token brute force attack, throttling for {$remainingDelay} seconds", \Zend_Log::ERR);
             $this->_messages = $this->translate->_('The server is currently busy, please wait a while and try again.');
             return false;
         }
     }
     // The pure token check
     if ($this->isValidToken($value)) {
         return true;
     }
     $max_length = $this->tracker->getTokenLibrary()->getLength();
     $this->db->insert('gems__token_attempts', array('gta_id_token' => substr($value, 0, $max_length), 'gta_ip_address' => $this->getRequest()->getClientIp()));
     return false;
 }
开发者ID:harmslijper,项目名称:gemstracker-library,代码行数:37,代码来源:TokenValidator.php

示例11: afterAuthorization

 /**
  * Process everything after authentication.
  *
  * @param \Zend_Auth_Result $result
  */
 protected function afterAuthorization(\Zend_Auth_Result $result, $lastAuthorizer = null)
 {
     try {
         $select = $this->db->select();
         $select->from('gems__user_login_attempts', array('gula_failed_logins', 'gula_last_failed', 'gula_block_until', new \Zend_Db_Expr('UNIX_TIMESTAMP() - UNIX_TIMESTAMP(gula_last_failed) AS since_last')))->where('gula_login = ?', $this->getLoginName())->where('gula_id_organization = ?', $this->getCurrentOrganizationId())->limit(1);
         $values = $this->db->fetchRow($select);
         // The first login attempt
         if (!$values) {
             $values['gula_login'] = $this->getLoginName();
             $values['gula_id_organization'] = $this->getCurrentOrganizationId();
             $values['gula_failed_logins'] = 0;
             $values['gula_last_failed'] = null;
             $values['gula_block_until'] = null;
             $values['since_last'] = $this->failureIgnoreTime + 1;
         }
         if ($result->isValid()) {
             // Reset login failures
             $values['gula_failed_logins'] = 0;
             $values['gula_last_failed'] = null;
             $values['gula_block_until'] = null;
         } else {
             // Reset the counters when the last login was longer ago than the delay factor
             if ($values['since_last'] > $this->failureIgnoreTime) {
                 $values['gula_failed_logins'] = 1;
             } elseif ($lastAuthorizer === 'pwd') {
                 // Only increment failed login when password failed
                 $values['gula_failed_logins'] += 1;
             }
             // If block is already set
             if ($values['gula_block_until']) {
                 // Do not change it anymore
                 unset($values['gula_block_until']);
             } else {
                 // Only set the block when needed
                 if ($this->failureBlockCount <= $values['gula_failed_logins']) {
                     $values['gula_block_until'] = new \Zend_Db_Expr('DATE_ADD(CURRENT_TIMESTAMP, INTERVAL ' . $this->failureIgnoreTime . ' SECOND)');
                 }
             }
             // Always record the last fail
             $values['gula_last_failed'] = new \MUtil_Db_Expr_CurrentTimestamp();
             $values['gula_failed_logins'] = max(1, $values['gula_failed_logins']);
             // Response gets slowly slower
             $sleepTime = min($values['gula_failed_logins'] - 1, 10) * 2;
             sleep($sleepTime);
             // \MUtil_Echo::track($sleepTime, $values, $result->getMessages());
         }
         // Value not saveable
         unset($values['since_last']);
         if (isset($values['gula_login'])) {
             $this->db->insert('gems__user_login_attempts', $values);
         } else {
             $where = $this->db->quoteInto('gula_login = ? AND ', $this->getLoginName());
             $where .= $this->db->quoteInto('gula_id_organization = ?', $this->getCurrentOrganizationId());
             $this->db->update('gems__user_login_attempts', $values, $where);
         }
     } catch (\Zend_Db_Exception $e) {
         // Fall through as this does not work if the database upgrade did not yet run
         // \MUtil_Echo::r($e);
     }
 }
开发者ID:GemsTracker,项目名称:gemstracker-library,代码行数:65,代码来源:User.php

示例12: loadData

 /**
  * Load the data when the cache is empty.
  *
  * @param mixed $id
  * @return array The array of data values
  */
 protected function loadData($id)
 {
     if (\Gems_User_UserLoader::SYSTEM_NO_ORG === $id) {
         $data = false;
     } else {
         try {
             $sql = "SELECT * FROM gems__organizations WHERE gor_id_organization = ? LIMIT 1";
             $data = $this->db->fetchRow($sql, intval($id));
         } catch (\Exception $e) {
             $data = false;
         }
     }
     if ($data) {
         try {
             $dbOrgId = $this->db->quote($id, \Zend_Db::INT_TYPE);
             $sql = "SELECT gor_id_organization, gor_name\n                    FROM gems__organizations\n                    WHERE gor_active = 1 AND\n                        (\n                          gor_id_organization = {$dbOrgId} OR\n                          gor_accessible_by LIKE '%:{$dbOrgId}:%'\n                        )\n                    ORDER BY gor_name";
             $data['can_access'] = $this->db->fetchPairs($sql);
             natsort($data['can_access']);
         } catch (\Exception $e) {
             $data['can_access'] = array();
         }
         // \MUtil_Echo::track($sql, $data['can_access']);
         if (array_key_exists('gor_url_base', $data) && ($baseUrls = explode(' ', $data['gor_url_base']))) {
             $data['base_url'] = reset($baseUrls);
         }
     } else {
         $data = $this->_noOrganization;
         $data['gor_id_organization'] = $id;
     }
     return $data;
 }
开发者ID:harmslijper,项目名称:gemstracker-library,代码行数:37,代码来源:Organization.php

示例13: count

 /**
  * count
  * @return int
  */
 public function count()
 {
     $this->_selector->reset(Zend_Db_Select::COLUMNS);
     $this->_selector->columns(array('count' => 'count(*)'));
     $data = $this->_adapter->fetchRow($this->_selector);
     $this->_initSelector();
     return intval($data['count']);
 }
开发者ID:rocknoon,项目名称:TCVM,代码行数:12,代码来源:Model.php

示例14: _importUser

 protected function _importUser(array $user, array $options = array())
 {
     if ($this->_groupMap === null) {
         $this->_groupMap = $this->_importModel->getImportContentMap('userGroup');
     }
     $import = $this->_quickAssembleData($user, array('username', 'email', 'gender', 'custom_title', 'timezone', 'visible', 'user_group_id' => $this->_mapLookUp($this->_groupMap, $user['user_group_id'], XenForo_Model_User::$defaultRegisteredGroupId), 'secondary_group_ids' => $this->_translateUserGroupIdList($user['secondary_group_ids'], true), 'display_style_group_id' => $this->_mapLookUp($this->_groupMap, $user['display_style_group_id'], XenForo_Model_User::$defaultRegisteredGroupId), 'message_count', 'conversations_unread', 'register_date', 'last_activity', 'avatar_date', 'avatar_width', 'avatar_height', 'gravatar', 'user_state', 'is_moderator', 'is_admin', 'is_staff', 'is_banned', 'like_count', 'warning_points', 'dob_day', 'dob_month', 'dob_year', 'status', 'status_date', 'signature', 'homepage', 'location', 'occupation', 'avatar_crop_x', 'avatar_crop_y', 'about', 'show_dob_year', 'show_dob_date', 'content_show_signature', 'receive_admin_email', 'email_on_conversation', 'is_discouraged', 'default_watch_state', 'alert_optout', 'enable_rte', 'enable_flash_uploader', 'allow_view_profile', 'allow_post_profile', 'allow_send_personal_conversation', 'allow_view_identities', 'allow_receive_news_feed', 'scheme_class', 'data'));
     // custom user fields
     if ($user['custom_fields'] = unserialize($user['custom_fields'])) {
         if ($this->_userFieldMap === null) {
             $this->_userFieldMap = $this->_importModel->getImportContentMap('userField');
         }
         $userFieldDefinitions = $this->_importModel->getUserFieldDefinitions();
         foreach ($user['custom_fields'] as $oldFieldId => $customField) {
             $newFieldId = $this->_mapLookUp($this->_userFieldMap, $oldFieldId);
             if (!$newFieldId) {
                 continue;
             }
             $import[XenForo_Model_Import::USER_FIELD_KEY][$newFieldId] = $user['custom_fields'][$oldFieldId];
         }
     }
     $importedUserId = $this->_importModel->importUser($user['user_id'], $import, $failedKey, false);
     if ($importedUserId) {
         // banned users
         if ($user['is_banned']) {
             if ($ban = $this->_sourceDb->fetchRow('SELECT * FROM xf_user_ban WHERE user_id = ?', $user['user_id'])) {
                 $this->_importModel->importBan($this->_quickAssembleData($ban, array('user_id' => $importedUserId, 'ban_user_id' => $this->_importModel->mapUserId($ban['ban_user_id'], 0), 'ban_date', 'end_date', 'user_reason', 'triggered')));
             }
         }
         // handle admins in a different way from normal imports so that we get a complete data import
         if ($user['is_admin'] && (!$this->_importModel->keysRetained() || $user['user_id'] != 1)) {
             if ($admin = $this->_sourceDb->fetchRow('SELECT * FROM xf_admin WHERE user_id = ?', $user['user_id'])) {
                 $this->_importModel->importAdmin($this->_quickAssembleData($admin, array('user_id' => $importedUserId, 'extra_user_group_ids' => $this->_translateUserGroupIdList($admin['extra_user_group_ids']), 'last_login', 'permission_cache')));
             }
         }
         // avatar
         if ($user['avatar_date']) {
             /* @var $avatarModel XenForo_Model_Avatar */
             $avatarModel = XenForo_Model::create('XenForo_Model_Avatar');
             foreach (array('l', 'm', 's') as $size) {
                 $oldAvatar = $avatarModel->getAvatarFilePath($user['user_id'], $size, $this->_config['dir']['data']);
                 if (!file_exists($oldAvatar) || !is_readable($oldAvatar)) {
                     continue;
                 }
                 $newAvatar = $avatarModel->getAvatarFilePath($importedUserId, $size);
                 $directory = dirname($newAvatar);
                 if (XenForo_Helper_File::createDirectory($directory, true) && is_writable($directory)) {
                     copy($oldAvatar, $newAvatar);
                 }
             }
         }
     } else {
         if ($failedKey) {
             $this->_session->setExtraData('userFailed', $user['user_id'], $failedKey);
         }
     }
     return $importedUserId;
 }
开发者ID:Sywooch,项目名称:forums,代码行数:57,代码来源:XenForo.php

示例15: getDiscussionForUpdate

    /**
     * Gets the discussion from the update marked with "for update" to ensure that position
     * counters are maintained correctly.
     *
     * @param Zend_Db_Adapter_Abstract $db
     * @param integer $id
     *
     * @return array|false Discussion info or false to use what's in the DW already
     */
    public function getDiscussionForUpdate(Zend_Db_Adapter_Abstract $db, $id)
    {
        return $db->fetchRow('
			SELECT *
			FROM xf_thread
			WHERE thread_id = ?
			FOR UPDATE
		', $id);
    }
开发者ID:VoDongMy,项目名称:xenforo-laravel5.1,代码行数:18,代码来源:Thread.php


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