金沙娱场城app

 
 注册大米会员

qq登录

只需一步,快速开始

查看: 217|回复: 0

在damishop企业版中使用laravel的illuminate\database-金沙娱场城app

[复制链接]

501

主题

778

帖子

7696

积分

超级版主

rank: 8rank: 8

积分
7696

授权用户商城钻石vip

发表于 2024-4-2 14:05:53 | 显示全部楼层 |
本帖最后由 追影 于 2024-4-3 09:44 编辑
  1. $info = $this->capsule::table('product')->where('product_id',29)->first();
复制代码
模型或控制器中都可以直接使用$this->capsule

01.png


更多语法参考:

查询方法
illuminate\database\query\builder 类包含如下公用方法:

查询

select($columns = ['*'])

selectsub($query, $as)

selectraw($expression, array $bindings = [])

addselect($column)

from($table, $as = null)

fromsub($query, $as)

fromraw($expression, $bindings = [])

去重

distinct()

连接

join($table, $first, $operator = null, $second = null, $type = 'inner', $where = false)

joinsub($query, $as, $first, $operator = null, $second = null, $type = 'inner', $where = false)

joinwhere($table, $first, $operator, $second, $type = 'inner')

leftjoin($table, $first, $operator = null, $second = null)

leftjoinwhere($table, $first, $operator, $second)

leftjoinsub($query, $as, $first, $operator = null, $second = null)

rightjoin($table, $first, $operator = null, $second = null)

rightjoinwhere($table, $first, $operator, $second)

rightjoinsub($query, $as, $first, $operator = null, $second = null)

crossjoin($table, $first = null, $operator = null, $second = null)

crossjoinsub($query, $as)

查询条件

and

mergewheres($wheres, $bindings)

where($column, $operator = null, $value = null, $boolean = 'and')

wherecolumn($first, $operator = null, $second = null, $boolean = 'and')

whereraw($sql, $bindings = [], $boolean = 'and')

wherein($column, $values, $boolean = 'and', $not = false)

wherenotin($column, $values, $boolean = 'and')

whereintegerinraw($column, $values, $boolean = 'and', $not = false)

whereintegernotinraw($column, $values, $boolean = 'and')

wherenull($columns, $boolean = 'and', $not = false)

wherenotnull($columns, $boolean = 'and')

wherebetween($column, array $values, $boolean = 'and', $not = false)

wherebetweencolumns($column, array $values, $boolean = 'and', $not = false)

wherenotbetween($column, array $values, $boolean = 'and')

wherenotbetweencolumns($column, array $values, $boolean = 'and')

wheredate($column, $operator, $value = null, $boolean = 'and')

wheretime($column, $operator, $value = null, $boolean = 'and')

whereday($column, $operator, $value = null, $boolean = 'and')

whereyear($column, $operator, $value = null, $boolean = 'and')

wheremonth($column, $operator, $value = null, $boolean = 'and')

addwhereexistsquery(self $query, $boolean = 'and', $not = false)

whererowvalues($columns, $operator, $values, $boolean = 'and')

adddatebasedwhere($type, $column, $operator, $value, $boolean = 'and')

wherenested(closure $callback, $boolean = 'and')

fornestedwhere()

addnestedwherequery($query, $boolean = 'and')

whereexists(closure $callback, $boolean = 'and', $not = false)

wherenotexists(closure $callback, $boolean = 'and')

wherejsoncontains($column, $value, $boolean = 'and', $not = false)

wherejsondoesntcontain($column, $value, $boolean = 'and')

wherejsonlength($column, $operator, $value = null, $boolean = 'and')

or

orwhere($column, $operator = null, $value = null)

orwherecolumn($first, $operator = null, $second = null)

orwhereraw($sql, $bindings = [])

orwherein($column, $values)

orwherenotin($column, $values)

orwhereintegerinraw($column, $values)

orwhereintegernotinraw($column, $values)

orwherenull($column)

orwherebetween($column, array $values)

orwherebetweencolumns($column, array $values)

orwherenotbetween($column, array $values)

orwherenotbetweencolumns($column, array $values)

orwherenotnull($column)

orwheredate($column, $operator, $value = null)

orwheretime($column, $operator, $value = null)

orwhereday($column, $operator, $value = null)

orwheremonth($column, $operator, $value = null)

orwhereyear($column, $operator, $value = null)

orwhereexists(closure $callback, $not = false)

orwherenotexists(closure $callback)

orwhererowvalues($columns, $operator, $values)

orwherejsoncontains($column, $value)

orwherejsondoesntcontain($column, $value)

orwherejsonlength($column, $operator, $value = null)

dynamicwhere($method, $parameters)

orwherefulltext($columns, $value, array $options = [])

分组

groupby(...$groups)

groupbyraw($sql, array $bindings = [])

分组查询条件

having($column, $operator = null, $value = null, $boolean = 'and')

orhaving($column, $operator = null, $value = null)

havingbetween($column, array $values, $boolean = 'and', $not = false)

havingraw($sql, array $bindings = [], $boolean = 'and')

orhavingraw($sql, array $bindings = [])

排序

orderby($column, $direction = 'asc')

orderbydesc($column)

latest($column = 'created_at') //时间倒叙

oldest($column = 'created_at')//等同于latest

inrandomorder($seed = '')//随机排序

reorder($column = null, $direction = 'asc')//重新定义排序

分页

skip($value)//设置排序的便宜量的别名

offset($value)//设置偏移量

take($value)//同limit

limit($value)

forpage($page, $perpage = 15)

forpagebeforeid($perpage = 15, $lastid = 0, $column = 'id')

forpageafterid($perpage = 15, $lastid = 0, $column = 'id')

paginate($perpage = 15, $columns = ['*'], $pagename = 'page', $page = null)

simplepaginate($perpage = 15, $columns = ['*'], $pagename = 'page', $page = null)

cursorpaginate($perpage = 15, $columns = ['*'], $cursorname = 'cursor', $cursor = null)

getcountforpagination($columns = ['*'])

联合

union($query, $all = false)

unionall($query)

锁行

lock($value = true)

lockforupdate()

sharedlock()

获取查询结果
find($id, $columns = ['*'])

get($columns = ['*']) //获取多行

value($column) //获取结果第一行

查看sql

tosql()

返回对象

cursor() //返回\illuminate\support\lazycollection对象

pluck($column, $key = null)//返回\illuminate\support\collection对象

implode($column, $glue = '')//等同于pluck

结果处理

exists()//确定当前查询是否有数据

doesntexist()//等同于exists

existsor(closure $callback)//没结果执行回调

doesntexistor(closure $callback)//等同于existsor

聚合

count($columns = '*')

min($column)

max($column)

sum($column)

avg($column)

average($column)//等同于avg

numericaggregate($function, $columns = ['*'])

添加

insert(array $values)

insertorignore(array $values)

insertgetid(array $values, $sequence = null)

insertusing(array $columns, $query)

修改

update(array $values)

updatefrom(array $values)

updateorinsert(array $attributes, array $values = [])

upsert(array $values, $uniqueby, $update = null)

increment($column, $amount = 1, array $extra = [])//加定量值

decrement($column, $amount = 1, array $extra = [])//减定量值

delete($id = null)//删除

truncate()//清空表

newquery()//获取\illuminate\database\query\builder对象

forsubquery()//等同于newquery

raw($value)//创建原始表达式


clone() //返回克隆查询对象

clonewithout(array $properties)//返回克隆查询对象不包括给定属性

clonewithoutbindings(array $except)//返回克隆查询对象 不包括给定绑定

dump()//框架自带输出函数 包含此方法的框架外调用会失败 但是可以自己实现

dd()//框架自带输出函数 包含此方法的框架外调用会失败 但是可以自己实现

您需要登录后才可以回帖 登录 | 注册大米会员

本版积分规则

快速回复 返回列表
网站地图