本文整理汇总了PHP中Illuminate\Database\Query\Builder::leftJoin方法的典型用法代码示例。如果您正苦于以下问题:PHP Builder::leftJoin方法的具体用法?PHP Builder::leftJoin怎么用?PHP Builder::leftJoin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Database\Query\Builder
的用法示例。
在下文中一共展示了Builder::leftJoin方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: leftJoinOn
/**
* @param $table
* @param $key $table.key
* @param bool $fkey $this->table.key
* @return $this
*/
public function leftJoinOn($table, $key, $fkey = false)
{
$fkey = $fkey ?: $key;
$key = starts_with($key, $table . '.') ? $key : $table . '.' . $key;
$fkey = starts_with($key, $this->table . '.') ? $fkey : $this->table . '.' . $fkey;
$this->operator = $this->operator->leftJoin($table, $key, '=', $fkey);
return $this;
}
示例2: leftJoin
/**
* Add a left join to the query.
*
* @param string $table
* @param string $first
* @param string $operator
* @param string $second
* @return \Illuminate\Database\Query\Builder|static
* @static
*/
public static function leftJoin($table, $first, $operator = null, $second = null)
{
return \Illuminate\Database\Query\Builder::leftJoin($table, $first, $operator, $second);
}
示例3: scopeWithAuthor
/**
* @param \Illuminate\Database\Query\Builder $query
* @return \Illuminate\Database\Query\Builder
*/
public function scopeWithAuthor($query)
{
return $query->leftJoin('users', 'users.id', '=', "{$this->table}.user_id")->addSelect("users.username as author");
}
示例4: scopeWithUser
/**
* Load thông tin user
*
* @param \Illuminate\Database\Query\Builder $query
*
* @return \Illuminate\Database\Query\Builder|static
*/
public function scopeWithUser($query)
{
$query->leftJoin('users', "{$this->table}.user_id", '=', "users.id")->addSelect('users.name as user_name', 'users.username as user_username');
return $query;
}
示例5: joinRevision
/**
* $query 에 join 된 쿼리를 리턴
*
* @param Builder $query query builder
* @return Builder
*/
public function joinRevision(Builder $query)
{
$config = $this->config;
$tableName = $query->from;
$table = $this->handler->getConfigHandler()->getRevisionTableName($config);
$query->leftJoin($table, function (JoinClause $join) use($tableName, $table, $config) {
$join->on(sprintf('%s.%s', $tableName, $config->get('joinColumnName')), '=', sprintf('%s.dynamicFieldTargetId', $table))->on(sprintf('%s.revisionId', $tableName), '=', sprintf('%s.revisionId', $table));
});
return $query;
}