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


PHP DatabaseManager::getTablePrefix方法代码示例

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


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

示例1: build

 /**
  * Builds the necessary fields on the object
  *
  * @return void
  */
 public function build()
 {
     $model = $this->config->getDataModel();
     $options = $this->suppliedOptions;
     $this->tablePrefix = $this->db->getTablePrefix();
     //set some options-based defaults
     $options['title'] = $this->validator->arrayGet($options, 'title', $options['column_name']);
     $options['sort_field'] = $this->validator->arrayGet($options, 'sort_field', $options['column_name']);
     //if the supplied item is an accessor, make this unsortable for the moment
     if (method_exists($model, camel_case('get_' . $options['column_name'] . '_attribute')) && $options['column_name'] === $options['sort_field']) {
         $options['sortable'] = false;
     }
     //however, if this is not a relation and the select option was supplied, str_replace the select option and make it sortable again
     if ($select = $this->validator->arrayGet($options, 'select')) {
         $options['select'] = str_replace('(:table)', $this->tablePrefix . $model->getTable(), $select);
     }
     //now we do some final organization to categorize these columns (useful later in the sorting)
     if (method_exists($model, camel_case('get_' . $options['column_name'] . '_attribute')) || $select) {
         $options['is_computed'] = true;
     } else {
         $options['is_included'] = true;
     }
     //run the visible property closure if supplied
     $visible = $this->validator->arrayGet($options, 'visible');
     if (is_callable($visible)) {
         $options['visible'] = $visible($this->config->getDataModel()) ? true : false;
     }
     $this->suppliedOptions = $options;
 }
开发者ID:dmitriyuch,项目名称:Laravel-Administrator,代码行数:34,代码来源:Column.php

示例2: updateRelationshipOptions

 /**
  * Given a model, field, type (filter or edit), and constraints (either int or array), returns an array of options
  *
  * @param string	$field
  * @param string	$type			//either 'filter' or 'edit'
  * @param array		$constraints	//an array of ids of the other model's items
  * @param array		$selectedItems	//an array of ids that are currently selected
  * @param string	$term			//the search term
  *
  * @return array
  */
 public function updateRelationshipOptions($field, $type, $constraints, $selectedItems, $term = null)
 {
     //first get the related model and fetch the field's options
     $model = $this->config->getDataModel();
     $relatedModel = $model->{$field}()->getRelated();
     $relatedTable = $relatedModel->getTable();
     $relatedKeyName = $relatedModel->getKeyName();
     $relatedKeyTable = $relatedTable . '.' . $relatedKeyName;
     $fieldObject = $this->getFieldObjectByName($field, $type);
     //if we can't find the field, return an empty array
     if (!$fieldObject) {
         return array();
     }
     //make sure we're grouping by the model's id
     $query = $relatedModel->newQuery();
     //set up the selects
     $query->select(array($this->db->raw($this->db->getTablePrefix() . $relatedTable . '.*')));
     //format the selected items into an array
     $selectedItems = $this->formatSelectedItems($selectedItems);
     //if this is an autocomplete field, check if there is a search term. If not, just return the selected items
     if ($fieldObject->getOption('autocomplete') && !$term) {
         if (sizeof($selectedItems)) {
             $this->filterQueryBySelectedItems($query, $selectedItems, $fieldObject, $relatedKeyTable);
             return $this->formatSelectOptions($fieldObject, $query->get());
         } else {
             return array();
         }
     }
     //applies constraints if there are any
     $this->applyConstraints($constraints, $query, $fieldObject);
     //if there is a search term, limit the result set by that term
     $this->filterBySearchTerm($term, $query, $fieldObject, $selectedItems, $relatedKeyTable);
     //perform any user-supplied options filter
     $filter = $fieldObject->getOption('options_filter');
     $filter($query);
     //finally we can return the options
     return $this->formatSelectOptions($fieldObject, $query->get());
 }
开发者ID:dmitriyuch,项目名称:Laravel-Administrator,代码行数:49,代码来源:Factory.php


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