当前位置: 首页>>代码示例>>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;未经允许,请勿转载。