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


PHP static::getTable方法代码示例

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


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

示例1: executeQuery

 protected static function executeQuery($command, array $attributes)
 {
     if (!count($attributes)) {
         return true;
     }
     $model = new static();
     if ($model->fireModelEvent('saving') === false) {
         return false;
     }
     $attributes = collect($attributes);
     $first = $attributes->first();
     if (!is_array($first)) {
         $attributes = collect([$attributes->toArray()]);
     }
     $keys = collect($attributes->first())->keys()->transform(function ($key) {
         return "`" . $key . "`";
     });
     $bindings = [];
     $query = $command . " into " . $model->getTable() . " (" . $keys->implode(",") . ") values ";
     $inserts = [];
     foreach ($attributes as $data) {
         $qs = [];
         foreach ($data as $value) {
             $qs[] = '?';
             $bindings[] = $value;
         }
         $inserts[] = '(' . implode(",", $qs) . ')';
     }
     $query .= implode(",", $inserts);
     \DB::connection($model->getConnectionName())->insert($query, $bindings);
     $model->fireModelEvent('saved', false);
 }
开发者ID:jdavidbakr,项目名称:replaceable-model,代码行数:32,代码来源:ReplaceableModel.php

示例2: isColumnNullable

 public static function isColumnNullable($column_name)
 {
     $instance = new static();
     // create an instance of the model to be able to get the table name
     $answer = DB::select(DB::raw("SELECT IS_NULLABLE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME='" . $instance->getTable() . "' AND COLUMN_NAME='" . $column_name . "' AND table_schema='" . env('DB_DATABASE') . "'"))[0];
     return $answer->IS_NULLABLE == 'YES' ? true : false;
 }
开发者ID:Ghitu,项目名称:crud,代码行数:7,代码来源:CrudTrait.php

示例3: allCached

 public static function allCached()
 {
     $instance = new static();
     $tableName = $instance->getTable();
     $eloquent = \Cache::remember($tableName . '_all', static::$expireCache, function () use($tableName, $instance) {
         return $instance->all();
     });
     return $eloquent;
 }
开发者ID:Metrakit,项目名称:dynamix,代码行数:9,代码来源:Eloquentizr.php

示例4: updateCache

 /**
  * Update all given Eloquent Model items in cache.
  * 
  * @access public
  * @static
  * @return bool
  */
 public static function updateCache($name = null)
 {
     self::initialize($name);
     $instance = new static();
     if (!Schema::hasTable($instance->getTable())) {
         return false;
     }
     Cache::forever(self::$cacheName, static::all());
     return true;
 }
开发者ID:misterpaladin,项目名称:cacheable,代码行数:17,代码来源:Cacheable.php

示例5: newInstanceWithOldInput

 /**
  * Lets us get a new instance populated with old input
  * if there is any input
  *
  * @return EloquentModel
  */
 public function newInstanceWithOldInput()
 {
     $instance = new static();
     foreach (\Input::old() as $key => $value) {
         if (\Schema::hasColumn($instance->getTable(), $key)) {
             $instance->{$key} = $value;
         }
     }
     return $instance;
 }
开发者ID:devisephp,项目名称:cms,代码行数:16,代码来源:DeviseEloquentAddons.php

示例6: getEnumValues

 /**
  * Get enum values from a column.
  *
  * @param  string $column
  *
  * @return array
  */
 public static function getEnumValues($column)
 {
     $instance = new static();
     $type = DB::select(DB::raw('SHOW COLUMNS FROM ' . $instance->getTable() . ' WHERE Field = "' . $column . '"'))[0]->Type;
     preg_match('/^enum\\((.*)\\)$/', $type, $matches);
     $enum = [];
     foreach (explode(',', $matches[1]) as $value) {
         $v = trim($value, "'");
         $enum = array_add($enum, $v, $v);
     }
     return $enum;
 }
开发者ID:DGTVE-VE,项目名称:ventana-educativa-2016,代码行数:19,代码来源:EnumTrait.php

示例7: possibleEnumValues

 public static function possibleEnumValues($name)
 {
     $instance = new static();
     $type = DB::select(DB::raw('SHOW COLUMNS FROM ' . $instance->getTable() . ' WHERE Field = "' . $name . '"'))[0]->Type;
     preg_match('/^enum\\((.*)\\)$/', $type, $matches);
     $enum = array();
     foreach (explode(',', $matches[1]) as $value) {
         $v = trim($value, "'");
         $enum[] = $v;
     }
     return $enum;
 }
开发者ID:buys-fran,项目名称:mtech-mis,代码行数:12,代码来源:HasEnums.php

示例8: getEnumFromField

 public static function getEnumFromField($name)
 {
     $instance = new static();
     // create an instance of the model to be able to get the table name
     $type = DB::select(DB::raw('SHOW COLUMNS FROM ' . $instance->getTable() . ' WHERE Field = "' . $name . '"'))[0]->Type;
     preg_match('/^enum\\((.*)\\)$/', $type, $matches);
     $enum = array();
     foreach (explode(',', $matches[1]) as $value) {
         $v = trim($value, "'");
         $enum[] = $v;
     }
     return $enum;
 }
开发者ID:jjsquad,项目名称:enumerable-field,代码行数:13,代码来源:EnumerableField.php

示例9: getSearchFields

 /**
  * Get all searchable fields
  *
  * @return array
  */
 public static function getSearchFields()
 {
     $model = new static();
     $fields = $model->search;
     if (empty($fields)) {
         $fields = Schema::getColumnListing($model->getTable());
         $others[] = $model->primaryKey;
         $others[] = $model->getUpdatedAtColumn() ?: 'created_at';
         $others[] = $model->getCreatedAtColumn() ?: 'updated_at';
         $others[] = method_exists($model, 'getDeletedAtColumn') ? $model->getDeletedAtColumn() : 'deleted_at';
         $fields = array_diff($fields, $model->getHidden(), $others);
     }
     return $fields;
 }
开发者ID:eezhal92,项目名称:plw-webdev,代码行数:19,代码来源:SearchTrait.php

示例10: scopeMostVoted

 public function scopeMostVoted($query)
 {
     // not working
     //return $query->with(['voteCounter' => function($q){
     //    return $q->orderBy('up', 'DESC');
     //}]);
     $relatedClass = new static();
     $class = $relatedClass->getMorphClass();
     $table = $relatedClass->getTable();
     $primary = $relatedClass->getKeyName();
     $query->selectRaw("{$table}.*, voteable_id, voteable_type, IFNULL(up, 0), IFNULL(down, 0), IFNULL(up, 0) - IFNULL(down, 0) as total")->leftJoin('voteable_counter', 'voteable_counter.voteable_id', '=', "{$table}.{$primary}")->where(function ($queryWhere) use($class) {
         return $queryWhere->where('voteable_type', '=', $class)->orWhere('voteable_type', '=', null);
     })->orderBy('total', 'DESC')->orderBy('up', 'DESC');
 }
开发者ID:laravolt,项目名称:votee,代码行数:14,代码来源:Voteable.php

示例11: schema

 /**
  * Return array of schema data for this model
  *
  * @return array
  */
 public static function schema()
 {
     $model = new static();
     $table = $model->getTable();
     $schema = \DB::getDoctrineSchemaManager($table);
     $columns = $schema->listTableColumns($table);
     $fields = array();
     foreach ($columns as $column) {
         $name = $column->getName();
         $type = $column->getType()->getName();
         $length = $column->getLength();
         $default = $column->getDefault();
         $fields[] = compact('name', 'type', 'length', 'default');
     }
     return $fields;
 }
开发者ID:rtconner,项目名称:laravel-plusplus,代码行数:21,代码来源:SchemaTrait.php

示例12: logIn

 /**
  * Método para verificar el logueo de un usuario.
  *
  * Si es logueo es satisfactorio retorna un arreglo con los datos del usuario.
  *
  * @param array $credentials Contiene los datos del usuario (user, password)
  * @param string $fieldId Contiene el campo de la tabla que representa el id.
  * @param string $fieldUser Contiene el campo de la tabla que representa el usuario.
  * @param string $fieldPass Contiene el campo de la tabla que representa el password.
  * @param string $type Contiene el tipo de usuario.
  *
  * @throws RestException Si $credentials no es un array.
  * @throws RestException Si falta algún argumento.
  * @throws RestException Si los argumentos son cadenas vacias.
  *
  * return array 
  *
  */
 public static function logIn($credentials, $fieldId, $fieldUser, $fieldPass, $type)
 {
     if (!is_array($credentials)) {
         throw new RestException(__FILE__, "logIn: credentials debe ser un array.", 500);
     }
     if (!isset($credentials['user']) or !isset($credentials['password'])) {
         throw new RestException(__FILE__, "logIn: faltan argumentos en las credenciales.", 400, ['message' => 'Faltan argumentos en las credenciales.']);
     }
     if ($credentials['user'] == "" or $credentials['password'] == "") {
         throw new RestException(__FILE__, "logIn: los argumentos no pueden estar vacios.", 400, ['message' => 'Los argumentos no pueden estar vacios.']);
     }
     $obj = new static();
     $results = $obj->select([$fieldId, $fieldUser, $fieldPass])->where([$fieldUser => $credentials['user'], $fieldPass => md5($credentials['password'])])->get();
     if ($results->count() != 1) {
         return false;
     }
     $data = ["data" => $results->first()->toArray(), "table" => $obj->getTable(), "type" => $type];
     return $data;
 }
开发者ID:stokekld,项目名称:ssocialRest,代码行数:37,代码来源:logInTrait.php

示例13: getByFileable

 /**
  * Get the files for fileable
  *
  * @param string $fileableId fileable identifier
  * @return Collection|static[]
  */
 public static function getByFileable($fileableId)
 {
     $model = new static();
     return $model->newQuery()->rightJoin($model->getFileableTable(), $model->getTable() . '.id', '=', $model->getFileableTable() . '.fileId')->where('fileableId', $fileableId)->select([$model->getTable() . '.*'])->get();
 }
开发者ID:xpressengine,项目名称:xpressengine,代码行数:11,代码来源:File.php

示例14: tableName

 public static function tableName()
 {
     $ins = new static();
     return $ins->getTable();
 }
开发者ID:windqyoung,项目名称:utils,代码行数:5,代码来源:Model.php

示例15: resolveConfiguration

 /**
  * kick start to just fetch the config
  * @return array
  */
 public static function resolveConfiguration()
 {
     static::$init = true;
     $self = new static();
     static::$init = false;
     $conf = array('table' => $self->getTable(), 'fieldConf' => $self->getFieldConfiguration(), 'db' => $self->db, 'fluid' => $self->fluid, 'primary' => $self->primary);
     unset($self);
     return $conf;
 }
开发者ID:mglinski,项目名称:pathfinder,代码行数:13,代码来源:cortex.php


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