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


PHP get_db函数代码示例

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


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

示例1: authenticate

 /**
  * Performs an authentication attempt.
  *
  * @return Zend_Auth_Result The result of the authentication.
  */
 public function authenticate()
 {
     // Use the parent method to authenticate the user.
     $result = parent::authenticate();
     // Check if user actually authenticated.
     if ($result->isValid()) {
         if (get_option('central_auth_email')) {
             // If user matching is by email, create email address.
             $lookup = $this->getUsername() . '@' . get_option('central_auth_email_domain');
             // Lookup the user by their email address in the user table.
             $user = get_db()->getTable('User')->findByEmail($lookup);
         } else {
             // Otherwise use the username.
             $lookup = $this->getUsername();
             // Lookup the user by their username in the user table.
             $user = get_db()->getTable('User')->findBySql('username = ?', array($lookup), true);
         }
         // If the user was found and active, return success.
         if ($user && $user->active) {
             return new Zend_Auth_Result(Zend_Auth_Result::SUCCESS, $user->id);
         }
         // Return that the user does not have an active account.
         return new Zend_Auth_Result(Zend_Auth_Result::FAILURE_IDENTITY_NOT_FOUND, $lookup, array(__('User matching "%s" not found.', $lookup)));
     }
     // Otherwise, log messages to error log.
     $messages = $result->getMessages();
     _log('CentralAuth_LdapAdapter: ' . implode("\n", $messages), Zend_Log::ERR);
     // Return the parent's result with error message meant for user.
     return new Zend_Auth_Result($result->getCode(), $result->getIdentity(), array($messages[0]));
 }
开发者ID:AdrienneSerra,项目名称:Digitalsc,代码行数:35,代码来源:LdapAdapter.php

示例2: update_news_pos

function update_news_pos($pos)
{
    $db = get_db();
    $category = new category_class('news');
    if ($pos == 1) {
        $category_id = $category->find_by_name('富豪报道');
        $category_id = $category_id->id;
        $type = 'richindex_news_';
    } else {
        $category_id = $category->find_by_name('创富者说');
        $category_id = $category_id->id;
        $type = 'richindex_news1_';
    }
    $table = new table_class('fb_page_pos');
    $db->echo_sql = true;
    $items = $db->query("select id,title,created_at,description,author from fb_news where category_id={$category_id} order by created_at desc limit 6");
    $exist_items = $table->find('all', array('conditions' => "name like '{$type}%' and (end_time <= now() or end_time is null)", 'order' => "name"));
    $db->echo_sql = false;
    $len = empty($exist_items) ? 0 : count($exist_items);
    for ($i = 0; $i < $len; $i++) {
        $exist_items[$i]->display = $items[$i]->title;
        $exist_items[$i]->description = $items[$i]->description;
        $exist_items[$i]->href = dynamic_news_url($items[$i]);
        $exist_items[$i]->statci_href = static_news_url($items[$i]);
        $exist_items[$i]->title = $items[$i]->title;
        $exist_items[$i]->alias = $items[$i]->author;
        $exist_items[$i]->end_time = dt_increase(1, 'h', $exist_itmes->end_time);
        $exist_items[$i]->save();
    }
}
开发者ID:sauger,项目名称:forbes_old,代码行数:30,代码来源:_richindex.php

示例3: itemGoogleMap

 public function itemGoogleMap($item = null, $width = '200px', $height = '200px', $hasBalloonForMarker = false, $markerHtmlClassName = 'geolocation_balloon')
 {
     $divId = "item-map-{$item->id}";
     $location = get_db()->getTable('Location')->findLocationByItem($item, true);
     // Only set the center of the map if this item actually has a location
     // associated with it
     if ($location) {
         $center['latitude'] = $location->latitude;
         $center['longitude'] = $location->longitude;
         $center['zoomLevel'] = $location->zoom_level;
         $center['show'] = true;
         if ($hasBalloonForMarker) {
             $titleLink = link_to_item(metadata($item, array('Dublin Core', 'Title'), array(), $item), array(), 'show', $item);
             $thumbnailLink = !item_image('thumbnail') ? '' : link_to_item(item_image('thumbnail', array(), 0, $item), array(), 'show', $item);
             $description = metadata($item, array('Dublin Core', 'Description'), array('snippet' => 150), $item);
             $center['markerHtml'] = '<div class="' . $markerHtmlClassName . '">' . '<div class="geolocation_balloon_title">' . $titleLink . '</div>' . '<div class="geolocation_balloon_thumbnail">' . $thumbnailLink . '</div>' . '<p class="geolocation_balloon_description">' . $description . '</p></div>';
         }
         $options = array();
         $options['mapType'] = get_option('geolocation_map_type');
         $center = js_escape($center);
         $options = js_escape($options);
         $style = "width: {$width}; height: {$height}";
         $html = '<div id="' . $divId . '" class="map geolocation-map" style="' . $style . '"></div>';
         $js = "var " . Inflector::variablize($divId) . ";";
         $js .= "OmekaMapSingle = new OmekaMapSingle(" . js_escape($divId) . ", {$center}, {$options}); ";
         $html .= "<script type='text/javascript'>{$js}</script>";
     } else {
         $html = '<p class="map-notification">' . __('This item has no location info associated with it.') . '</p>';
     }
     return $html;
 }
开发者ID:regan008,项目名称:WearingGayHistory-Plugins,代码行数:31,代码来源:ItemGoogleMap.php

示例4: init

 /**
  * Initialize the form.
  */
 public function init()
 {
     parent::init();
     $this->_columnDelimiter = CsvImport_RowIterator::getDefaultColumnDelimiter();
     $this->_fileDelimiter = CsvImport_ColumnMap_File::getDefaultFileDelimiter();
     $this->_tagDelimiter = CsvImport_ColumnMap_Tag::getDefaultTagDelimiter();
     $this->_elementDelimiter = CsvImport_ColumnMap_Element::getDefaultElementDelimiter();
     $this->setAttrib('id', 'csvimport');
     $this->setMethod('post');
     $this->_addFileElement();
     $values = get_db()->getTable('ItemType')->findPairsForSelectForm();
     $values = array('' => __('Select Item Type')) + $values;
     $this->addElement('checkbox', 'omeka_csv_export', array('label' => __('Use an export from Omeka CSV Report'), 'description' => __('Selecting this will override the options below.')));
     $this->addElement('checkbox', 'automap_columns_names_to_elements', array('label' => __('Automap Column Names to Elements'), 'description' => __('Automatically maps columns to elements based on their column names. The column name must be in the form: <br/> {ElementSetName}:{ElementName}'), 'value' => true));
     $this->addElement('select', 'item_type_id', array('label' => __('Select Item Type'), 'multiOptions' => $values));
     $values = get_db()->getTable('Collection')->findPairsForSelectForm();
     $values = array('' => __('Select Collection')) + $values;
     $this->addElement('select', 'collection_id', array('label' => __('Select Collection'), 'multiOptions' => $values));
     $this->addElement('checkbox', 'items_are_public', array('label' => __('Make All Items Public?')));
     $this->addElement('checkbox', 'items_are_featured', array('label' => __('Feature All Items?')));
     $this->_addColumnDelimiterElement();
     $this->_addTagDelimiterElement();
     $this->_addFileDelimiterElement();
     $this->_addElementDelimiterElement();
     $this->applyOmekaStyles();
     $this->setAutoApplyOmekaStyles(false);
     $submit = $this->createElement('submit', 'submit', array('label' => __('Next'), 'class' => 'submit submit-medium'));
     $submit->setDecorators(array('ViewHelper', array('HtmlTag', array('tag' => 'div', 'class' => 'csvimportnext'))));
     $this->addElement($submit);
 }
开发者ID:rshiggin,项目名称:omeka-custom-exhibit,代码行数:33,代码来源:Main.php

示例5: preDispatch

 /**
  * Set the filters pre-dispatch only on configured routes.
  * 
  * @param Zend_Controller_Request_Abstract
  */
 public function preDispatch($request)
 {
     $db = get_db();
     // Some routes don't have a default module, which resolves to NULL.
     $currentModule = is_null($request->getModuleName()) ? 'default' : $request->getModuleName();
     $currentController = $request->getControllerName();
     $currentAction = $request->getActionName();
     // Allow plugins to register routes that contain form inputs rendered by
     // Omeka_View_Helper_ElementForm::_displayFormInput().
     $routes = apply_filters('simple_vocab_routes', $this->_defaultRoutes);
     // Apply filters to defined routes.
     foreach ($routes as $route) {
         // Check registered routed against the current route.
         if ($route['module'] != $currentModule || $route['controller'] != $currentController || !in_array($currentAction, $route['actions'])) {
             continue;
         }
         // Add the filters if the current route is registered. Cache the
         // vocab terms for use by the filter callbacks.
         $select = $db->getTable('SimpleVocabTerm')->getSelect()->reset(Zend_Db_Select::COLUMNS)->columns(array('element_id', 'terms'));
         $this->_simpleVocabTerms = $db->fetchPairs($select);
         foreach ($this->_simpleVocabTerms as $element_id => $terms) {
             $element = $db->getTable('Element')->find($element_id);
             $elementSet = $db->getTable('ElementSet')->find($element->element_set_id);
             add_filter(array('ElementInput', 'Item', $elementSet->name, $element->name), array($this, 'filterElementInput'));
         }
         // Once the filter is applied for one route there is no need to
         // continue looping the routes.
         break;
     }
 }
开发者ID:rameysar,项目名称:Omeka-Grinnell-RomanCiv,代码行数:35,代码来源:SelectFilter.php

示例6: hookConfigForm

 public function hookConfigForm()
 {
     $table = get_db()->getTable('Element');
     $select = $table->getSelect()->order('elements.element_set_id')->order('ISNULL(elements.order)')->order('elements.order');
     $elements = $table->fetchObjects($select);
     include 'config-form.php';
 }
开发者ID:sgbalogh,项目名称:peddler_clone5,代码行数:7,代码来源:FacetByMetadataPlugin.php

示例7: fc_isFedoraStream

/**
 * Tests whether an item contains Fedora streams.
 *
 * @param Item $item The item.
 * @return bool Is the item a Fedora stream?
 * @author Eric Rochester <erochest@virginia.edu>
 **/
function fc_isFedoraStream($item = null)
{
    $item = $item ? $item : get_current_record('item');
    $objects = get_db()->getTable('FedoraConnectorObject');
    $isStream = $item && $objects->findByItem($item);
    return $isStream;
}
开发者ID:KelvinSmithLibrary,项目名称:playhouse,代码行数:14,代码来源:FedoraConnectorFunctions.php

示例8: updateFromText

 public function updateFromText($vocab_id, $text)
 {
     //set this to all rows
     $deleted = array();
     $added = array();
     $termObjs = $this->fetchObjects("Select `term` from omeka_svp_terms where vocab_id = " . $vocab_id);
     foreach ($termObjs as $termObj) {
         $deleted[] = trim($termObj['term']);
     }
     $terms = $this->_parseText($text);
     foreach ($terms as $term) {
         $i = array_search(trim($term), $deleted);
         if ($i !== false) {
             unset($deleted[$i]);
         } else {
             $added[] = $term;
         }
     }
     foreach ($deleted as $delete) {
         $sql = 'delete from omeka_svp_terms where vocab_id = "' . $vocab_id . '" and term = "' . trim($delete) . '"';
         //die($sql);
         get_db()->query($sql);
     }
     foreach ($added as $add) {
         $term = trim($term);
         $svpTerm = new SvpTerm();
         $svpTerm->vocab_id = $vocab_id;
         $svpTerm->term = $add;
         $svpTerm->save();
     }
     if (!empty($added) && !empty($deleted)) {
         return array('add' => array_values($added), 'delete' => array_values($deleted));
     }
     return false;
 }
开发者ID:HCDigitalScholarship,项目名称:learning-omeka,代码行数:35,代码来源:SvpTerm.php

示例9: getRecordIdentifier

 /**
  * Return the identifier of a record, if any. It can be sanitized.
  *
  * @param Omeka_Record_AbstractRecord|string $record
  * @param boolean $rawEncoded Sanitize the identifier for http or not.
  * @return string Identifier of the record, if any, else empty string.
  */
 public function getRecordIdentifier($record, $rawEncoded = true)
 {
     // Get the current record from the view if passed as a string.
     if (is_string($record)) {
         $record = $this->view->getCurrentRecord($record);
     }
     if (empty($record)) {
         return '';
     }
     if (!$record instanceof Omeka_Record_AbstractRecord) {
         throw new Omeka_View_Exception(__('Invalid record passed while getting record URL.'));
     }
     // Use a direct query in order to improve speed.
     $db = get_db();
     $elementId = (int) get_option('clean_url_identifier_element');
     $bind = array(get_class($record), $record->id);
     $prefix = get_option('clean_url_identifier_prefix');
     if ($prefix) {
         // Keep only the identifier without the configured prefix.
         $prefixLength = strlen($prefix) + 1;
         $sqlSelect = 'SELECT TRIM(SUBSTR(element_texts.text, ' . $prefixLength . '))';
         $sqlWhereText = 'AND element_texts.text LIKE ?';
         $bind[] = $prefix . '%';
     } else {
         $sqlSelect = 'SELECT element_texts.text';
         $sqlWhereText = '';
     }
     $sql = "\n            {$sqlSelect}\n            FROM {$db->ElementText} element_texts\n            WHERE element_texts.element_id = '{$elementId}'\n                AND element_texts.record_type = ?\n                AND element_texts.record_id = ?\n                {$sqlWhereText}\n            ORDER BY element_texts.id\n            LIMIT 1\n        ";
     $identifier = $db->fetchOne($sql, $bind);
     return $rawEncoded ? rawurlencode($identifier) : $identifier;
 }
开发者ID:AdrienneSerra,项目名称:Digitalsc,代码行数:38,代码来源:GetRecordIdentifier.php

示例10: run

 /**
  * Runs the delete import process.
  * 
  * @param array $args Required arguments to run the process.
  */
 public function run($args)
 {
     ini_set('memory_limit', '500M');
     $this->_db = get_db();
     $this->_processId = $args['processId'];
     $this->_deleteImport();
 }
开发者ID:Daniel-KM,项目名称:ZoteroImport,代码行数:12,代码来源:DeleteImportProcess.php

示例11: getComments

 public function getComments($options = array(), $record_id = null, $record_type = null)
 {
     $request = Zend_Controller_Front::getInstance()->getRequest();
     $params = $request->getParams();
     if (!$record_id) {
         $record_id = $this->_getRecordId($params);
     }
     if (!$record_type) {
         $record_type = $this->_getRecordType($params);
     }
     $db = get_db();
     $commentTable = $db->getTable('Comment');
     $searchParams = array('record_type' => $record_type, 'record_id' => $record_id);
     if (isset($options['approved'])) {
         $searchParams['approved'] = $options['approved'];
     }
     if (!is_allowed('Commenting_Comment', 'update-approved')) {
         $searchParams['flagged'] = 0;
         $searchParams['is_spam'] = 0;
     }
     $select = $commentTable->getSelectForFindBy($searchParams);
     if (isset($options['order'])) {
         $select->order("ORDER BY added " . $options['order']);
     }
     return $commentTable->fetchObjects($select);
 }
开发者ID:regan008,项目名称:WearingGayHistory-Plugins,代码行数:26,代码来源:GetComments.php

示例12: setPutData

 /**
  * Set PUT data to an item type.
  *
  * @param ItemType $data
  * @param mixed $data
  */
 public function setPutData(Omeka_Record_AbstractRecord $record, $data)
 {
     if (isset($data->name)) {
         $record->name = $data->name;
     }
     if (isset($data->description)) {
         $record->description = $data->description;
     }
     if (isset($data->elements) && is_array($data->elements)) {
         $db = get_db();
         // Delete the existing item type elements.
         $sql = "DELETE FROM {$db->ItemTypesElements} WHERE item_type_id = ?";
         $db->query($sql, $record->id);
         // Insert new item type elements.
         $elementTable = $db->getTable('Element');
         $i = 1;
         foreach ($data->elements as $element) {
             if (!is_object($element) || !isset($element->id)) {
                 continue;
             }
             // Ignore if the element does not exist.
             if (!$elementTable->exists($element->id)) {
                 continue;
             }
             $itemTypesElement = new ItemTypesElements();
             $itemTypesElement->item_type_id = $record->id;
             $itemTypesElement->element_id = $element->id;
             $itemTypesElement->order = $i;
             $itemTypesElement->save();
             $i++;
         }
     }
 }
开发者ID:kluther,项目名称:MappingThe4th,代码行数:39,代码来源:ItemType.php

示例13: getUri

 /**
  * Get a URI for a "stored" file.
  *
  * @param string $path
  * @return string URI
  */
 public function getUri($path)
 {
     list($size, $filename) = explode('/', $path, 2);
     $db = get_db();
     $select = $db->select()->from(array("f" => $db->File), array('metadata'));
     $select->where('f.filename = ?', $filename);
     $metadata = $db->getTable('File')->fetchOne($select);
     if ($metadata == '{"iiif":{}}') {
         return '/plugins/Iiif/views/public/img/placeholder.png';
     }
     $metadata = json_decode($metadata, True);
     if (isset($metadata) and array_key_exists('iiif', $metadata) and array_key_exists('@id', $metadata['iiif'])) {
         $base_image_url = $metadata['iiif']['@id'];
     } else {
         # Fallback to Omeka_Storage_Adapter_Filesystem method
         return $this->_webDir . '/' . $path;
     }
     $square_thumbnail_size = get_option('square_thumbnail_constraint');
     $thumbnail_size = get_option('thumbnail_constraint');
     $fullsize_size = get_option('fullsize_constraint');
     $mapping = array('square_thumbnails' => "{$square_thumbnail_size},{$square_thumbnail_size}", 'thumbnails' => "!{$thumbnail_size},{$thumbnail_size}", 'fullsize' => "!{$fullsize_size},{$fullsize_size}", 'original' => 'full');
     if ($size == 'square_thumbnails') {
         $region = 'square';
     } else {
         $region = 'full';
     }
     return $base_image_url . "/{$region}/" . $mapping[$size] . "/0/native.jpg";
 }
开发者ID:klokantech,项目名称:omeka-plugin-IIIF,代码行数:34,代码来源:Iiif.php

示例14: findByVocabAndPropertyName

 public function findByVocabAndPropertyName($vocabUri, $predName)
 {
     $db = get_db();
     $select = $this->getSelect()->join(array($db->RecordRelationsVocabulary => $db->RecordRelationsVocabulary), "{$db->RecordRelationsVocabulary}.namespace_uri = '{$vocabUri}'", array())->where("vocabulary_id = {$db->RecordRelationsVocabulary}.id")->where("local_part = ?", $predName);
     $prop = $this->fetchObject($select);
     return $prop;
 }
开发者ID:sgbalogh,项目名称:peddler_clone5,代码行数:7,代码来源:RecordRelationsProperty.php

示例15: getRecordTypeIdentifiers

 /**
  * Return identifiers for a record type, if any. It can be sanitized.
  *
  * @param string $recordType Should be "Collection", "Item" or "File".
  * @param boolean $rawEncoded Sanitize the identifier for http or not.
  * @return array Associative array of record id and identifiers.
  */
 public function getRecordTypeIdentifiers($recordType, $rawEncoded = true)
 {
     if (!in_array($recordType, array('Collection', 'Item', 'File'))) {
         return array();
     }
     // Use a direct query in order to improve speed.
     $db = get_db();
     $elementId = (int) get_option('clean_url_identifier_element');
     $bind = array();
     $prefix = get_option('clean_url_identifier_prefix');
     if ($prefix) {
         // Keep only the identifier without the configured prefix.
         $prefixLenght = strlen($prefix) + 1;
         $sqlSelect = 'SELECT element_texts.record_id, TRIM(SUBSTR(element_texts.text, ' . $prefixLenght . '))';
         $sqlWereText = 'AND element_texts.text LIKE ?';
         $bind[] = $prefix . '%';
     } else {
         $sqlSelect = 'SELECT element_texts.record_id, element_texts.text';
         $sqlWereText = '';
     }
     // The "order by id DESC" allows to get automatically the first row in
     // php result and avoids a useless subselect in sql (useless because in
     // almost all cases, there is only one identifier).
     $sql = "\n            {$sqlSelect}\n            FROM {$db->ElementText} element_texts\n            WHERE element_texts.element_id = '{$elementId}'\n                AND element_texts.record_type = '{$recordType}'\n                {$sqlWereText}\n            ORDER BY element_texts.record_id, element_texts.id DESC\n        ";
     $result = $db->fetchPairs($sql, $bind);
     return $rawEncoded ? array_map('rawurlencode', $result) : $result;
 }
开发者ID:AdrienneSerra,项目名称:Digitalsc,代码行数:34,代码来源:GetRecordTypeIdentifiers.php


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