當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Builder::from方法代碼示例

本文整理匯總了PHP中Illuminate\Database\Eloquent\Builder::from方法的典型用法代碼示例。如果您正苦於以下問題:PHP Builder::from方法的具體用法?PHP Builder::from怎麽用?PHP Builder::from使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Illuminate\Database\Eloquent\Builder的用法示例。


在下文中一共展示了Builder::from方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getRelationCountQueryForSelfRelation

 /**
  * Add the constraints for a relationship count query on the same table.
  *
  * @param  \Illuminate\Database\Eloquent\Builder  $query
  * @param  \Illuminate\Database\Eloquent\Builder  $parent
  * @return \Illuminate\Database\Eloquent\Builder
  */
 public function getRelationCountQueryForSelfRelation(Builder $query, Builder $parent)
 {
     $query->select(new Expression('count(*)'));
     $query->from($query->getModel()->getTable() . ' as ' . ($hash = $this->getRelationCountHash()));
     $key = $this->wrap($this->getQualifiedParentKeyName());
     return $query->where($hash . '.' . $this->getPlainForeignKey(), '=', new Expression($key));
 }
開發者ID:nsoimaru,項目名稱:Laravel51-starter,代碼行數:14,代碼來源:HasOneOrMany.php

示例2: getRelationQuery

 /**
  * @param EloquentBuilder $query
  * @param EloquentBuilder $parent
  * @param array $columns
  *
  * @return mixed
  */
 public function getRelationQuery(EloquentBuilder $query, EloquentBuilder $parent, $columns = ['*'])
 {
     $query->select($columns);
     $table = $query->getModel()->getTable();
     $query->from($table . ' as ' . ($hash = $this->getRelationCountHash()));
     $grammar = $query->getQuery()->getGrammar();
     $table = $grammar->wrapTable($table);
     $hash = $grammar->wrapTable($hash);
     $lft = $grammar->wrap($this->parent->getLftName());
     $rgt = $grammar->wrap($this->parent->getRgtName());
     return $query->whereRaw("{$hash}.{$lft} between {$table}.{$lft} + 1 and {$table}.{$rgt}");
 }
開發者ID:nutsdo,項目名稱:nong-store,代碼行數:19,代碼來源:DescendantsRelation.php

示例3: constrainWhereAssignedTo

 /**
  * Constrain the given roles query to those that were assigned to the given authorities.
  *
  * @param  \Illuminate\Database\Eloquent\Builder  $query
  * @param  string|\Illuminate\Database\Eloquent\Model|\Illuminate\Database\Eloquent\Collection  $model
  * @param  array  $keys
  * @return void
  */
 public function constrainWhereAssignedTo($query, $model, array $keys = null)
 {
     list($model, $keys) = Helper::extractModelAndKeys($model, $keys);
     $query->whereExists(function ($query) use($model, $keys) {
         $table = $model->getTable();
         $key = "{$table}.{$model->getKeyName()}";
         $pivot = Models::table('assigned_roles');
         $roles = Models::table('roles');
         $prefix = Models::prefix();
         $query->from($table)->join($pivot, $key, '=', $pivot . '.entity_id')->whereRaw("{$prefix}{$pivot}.role_id = {$prefix}{$roles}.id")->where("{$pivot}.entity_type", $model->getMorphClass())->whereIn($key, $keys);
     });
 }
開發者ID:JosephSilber,項目名稱:bouncer,代碼行數:20,代碼來源:Roles.php

示例4: getRelationCountQueryForSelfJoin

 /**
  * Add the constraints for a relationship count query on the same table.
  *
  * @param  \Illuminate\Database\Eloquent\Builder  $query
  * @param  \Illuminate\Database\Eloquent\Builder  $parent
  * @return \Illuminate\Database\Eloquent\Builder
  */
 public function getRelationCountQueryForSelfJoin(Builder $query, Builder $parent)
 {
     $query->select(new Expression('count(*)'));
     $tablePrefix = $this->query->getQuery()->getConnection()->getTablePrefix();
     $query->from($this->table . ' as ' . $tablePrefix . ($hash = $this->getRelationCountHash()));
     $key = $this->wrap($this->getQualifiedParentKeyName());
     return $query->where($hash . '.' . $this->foreignKey, '=', new Expression($key));
 }
開發者ID:mawaha,項目名稱:tracker,代碼行數:15,代碼來源:BelongsToMany.php

示例5: getRelationCountQueryForSelfJoin

 /**
  * Add the constraints for a relationship count query on the same table.
  *
  * @param  \Illuminate\Database\Eloquent\Builder  $query
  * @param  \Illuminate\Database\Eloquent\Builder  $parent
  * @return \Illuminate\Database\Eloquent\Builder
  */
 public function getRelationCountQueryForSelfJoin(Builder $query, Builder $parent)
 {
     $query->select(new Expression('count(*)'));
     $query->from($this->related->getTable() . ' as ' . ($hash = $this->getRelationCountHash()));
     $this->related->setTable($hash);
     $this->setJoin($query);
     return parent::getRelationCountQuery($query, $parent);
 }
開發者ID:m-gamal,項目名稱:crm,代碼行數:15,代碼來源:BelongsToMany.php

示例6: getRelationQueryForSelfJoin

 /**
  * Add the constraints for a relationship query on the same table.
  *
  * @param  \Illuminate\Database\Eloquent\Builder  $query
  * @param  \Illuminate\Database\Eloquent\Builder  $parent
  * @param  array|mixed  $columns
  * @return \Illuminate\Database\Eloquent\Builder
  */
 public function getRelationQueryForSelfJoin(Builder $query, Builder $parent, $columns = ['*'])
 {
     $query->select($columns);
     $query->from($this->table . ' as ' . ($hash = $this->getRelationCountHash()));
     $key = $this->wrap($this->getQualifiedParentKeyName());
     return $query->where($hash . '.' . $this->foreignKey, '=', new Expression($key));
 }
開發者ID:bmitch,項目名稱:framework,代碼行數:15,代碼來源:BelongsToMany.php

示例7: mergeQueries

 /**
  * Merge our cloned query builder with the original one.
  *
  * @param \Illuminate\Database\Eloquent\Builder $clone
  * @param \Illuminate\Database\Eloquent\Builder $original
  */
 protected function mergeQueries(Builder $clone, Builder $original)
 {
     $original->from(DB::connection($this->connection)->raw("({$clone->toSql()}) as `{$this->getTable()}`"));
     $original->mergeBindings($clone->getQuery());
 }
開發者ID:singgihsap,項目名稱:elearning,代碼行數:11,代碼來源:SearchableTrait.php

示例8: getRelationCountQueryForSelfJoin

 /**
  * Add the constraints for a relationship count query on the same table.
  *
  * @param  \Illuminate\Database\Eloquent\Builder  $query
  * @param  \Illuminate\Database\Eloquent\Builder  $parent
  * @return \Illuminate\Database\Eloquent\Builder
  */
 public function getRelationCountQueryForSelfJoin(Builder $query, Builder $parent)
 {
     $query->select(new \Illuminate\Database\Query\Expression('count(*)'));
     $query->from($this->table . ' as ' . ($hash = $this->getRelationCountHash()));
     $key = $this->wrap($this->getQualifiedParentKeyName());
     return $query->where($hash . '.' . $this->foreignKey, '=', new \Illuminate\Database\Query\Expression($key));
 }
開發者ID:aysenli,項目名稱:laravel-admin-1,代碼行數:14,代碼來源:BelongsToMany.php

示例9: getRelationQueryForSelfJoin

 /**
  * Add the constraints for a relationship query on the same table.
  *
  * @param  \Illuminate\Database\Eloquent\Builder  $query
  * @param  \Illuminate\Database\Eloquent\Builder  $parent
  * @param  array|mixed  $columns
  * @return \Illuminate\Database\Eloquent\Builder
  */
 public function getRelationQueryForSelfJoin(Builder $query, Builder $parent, $columns = ['*'])
 {
     $query->select($columns);
     $query->from($this->related->getTable() . ' as ' . ($hash = $this->getRelationCountHash()));
     $this->related->setTable($hash);
     $this->setJoin($query);
     return parent::getRelationQuery($query, $parent, $columns);
 }
開發者ID:jeandrocouto,項目名稱:warmupdelivery,代碼行數:16,代碼來源:BelongsToMany.php

示例10: mergeQueries

 /**
  * Merge our cloned query builder with the original one.
  *
  * @param \Illuminate\Database\Eloquent\Builder $clone
  * @param \Illuminate\Database\Eloquent\Builder $original
  */
 protected function mergeQueries(Builder $clone, Builder $original)
 {
     if ($this->getDatabaseDriver() == 'pgsql') {
         $original->from(DB::connection($this->connection)->raw("({$clone->toSql()}) as {$this->getTable()}"));
     } else {
         $original->from(DB::connection($this->connection)->raw("({$clone->toSql()}) as `{$this->getTable()}`"));
     }
     $original->mergeBindings($clone->getQuery());
 }
開發者ID:Rahul-Giri,項目名稱:searchable,代碼行數:15,代碼來源:SearchableTrait.php

示例11: mergeQueries

 /**
  * Merge our cloned query builder with the original one.
  *
  * @param \Illuminate\Database\Eloquent\Builder $clone
  * @param \Illuminate\Database\Eloquent\Builder $original
  */
 protected function mergeQueries(Builder $clone, Builder $original)
 {
     $prefix = App::$Database->connection($this->connection)->getTablePrefix();
     $tableName = $prefix . $this->getTable();
     if ($this->getDatabaseDriver() == 'pgsql') {
         $original->from(App::$Database->connection($this->connection)->raw("({$clone->toSql()}) as {$tableName}"));
     } else {
         $original->from(App::$Database->connection($this->connection)->raw("({$clone->toSql()}) as `{$tableName}`"));
     }
     $original->mergeBindings($clone->getQuery());
 }
開發者ID:phpffcms,項目名稱:searchable,代碼行數:17,代碼來源:SearchableTrait.php

示例12: scopeExceptGeneral

 /**
  * 擴展查詢,獲取排除通識素質課的課程數據
  * @author FuRongxin
  * @date    2016-03-09
  * @version 2.0
  * @param   \Illuminate\Database\Eloquent\Builder $query 查詢對象
  * @return  \Illuminate\Database\Eloquent\Builder 查詢對象
  */
 public function scopeExceptGeneral($query)
 {
     return $query->whereNotExists(function ($query) {
         $query->from('pk_kczy AS a')->whereRaw('t_a.nd = t_pk_kczy.nd AND t_a.xq = t_pk_kczy.xq AND t_a.zsjj = t_pk_kczy.zsjj AND t_a.kcxh = t_pk_kczy.kcxh')->wherePt('T')->where(function ($query) {
             $query->whereXz('W')->orWhere('xz', '=', 'I')->orWhere('xz', '=', 'Y')->orWhere('xz', '=', 'Q');
         });
     });
 }
開發者ID:rxfu,項目名稱:student,代碼行數:16,代碼來源:Mjcourse.php

示例13: scopeFieldId

 /**
  * Filter by Field ID
  *
  * @param  \Illuminate\Database\Eloquent\Builder $query
  * @param  int                                   $fieldId
  * @return \Illuminate\Database\Eloquent\Builder
  */
 public function scopeFieldId(Builder $query, $fieldId)
 {
     return $query->from('channel_grid_field_' . $fieldId);
 }
開發者ID:khaliqgant,項目名稱:Deep,代碼行數:11,代碼來源:GridRow.php

示例14: scopeStudied

 /**
  * 擴展查詢,獲取已修讀課程列表
  * @author FuRongxin
  * @date    2016-03-10
  * @version 2.0
  * @param   \Illuminate\Database\Eloquent\Builder $query 查詢對象
  * @param   object $user 用戶對象
  * @return  \Illuminate\Database\Eloquent\Builder 查詢對象
  */
 public function scopeStudied($query, $user)
 {
     return $query->whereXh($user->xh)->whereNotExists(function ($query) {
         $query->from('xk_xkxx AS a')->whereNd(session('year'))->whereXq(session('term'))->whereRaw('t_a.xh = t_xk_xkxx.xh AND t_a.kcxh = t_xk_xkxx.kcxh');
     });
 }
開發者ID:rxfu,項目名稱:student,代碼行數:15,代碼來源:Selcourse.php


注:本文中的Illuminate\Database\Eloquent\Builder::from方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。