Download the PHP package yesccx/laravel-db-query without Composer

On this page you can find all versions of the php package yesccx/laravel-db-query. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-db-query

Laravel-DB-Query

Laravel 中便捷的进行原生 MYSQL 语句查询

For Laravel 5 Latest Stable Version Latest Unstable Version Total Downloads License

目录

安装

运行环境

运行环境要求
PHP ^8.1.0
Laravel Framework ^9.0

通过Composer引入依赖包

通过终端进入项目根目录,执行以下命令引入依赖包:

发布配置文件

如果需要额外配置,可选择 发布配置文件

开始使用

DBQuery 查询

简单查询

将连接配置名传递给 connection 方法

连接配置通常来自 database.php 配置文件中的 connections

还可以直接传入连接配置( 目前仅支持 MYSQL 驱动

模板查询

在语句中定义占位符后,可以使用链式方法如 whereselectgroup byorder by 等进行查询

目前支持的占位符:

类型 示例
@WHERE@ select * from a where id > 1 and (@WHERE@)
@COLUMNS@ select @COLUMNS@ from a
@GROUPBY@ select * from a group by @GROUPBY@
@HAVING@ select * from a group by id having @HAVING@
@ORDERBY@ select * from a order by @ORDERBY@
@LIMIT@ select * from a limit @LIMIT@
@OFFSET@ select * from a offset @OFFSET@

查询缓存

默认情况下关闭查询缓存,可以通过配置 db-query.cache.enabled 进行开启,开启后传递给 cache 方法一个有效时间(单位秒)对查询结果进行缓存

通常情况下可以直接配置 env 中的 YDQ_CACHE_ENABLED 进行开启

如果需要指定缓存驱动、前缀等,可以通过配置 db-query.cache.driver

更多查询方法

查询允许链式的使用 Laravel Illuminate\Database\Query\Builder 类中支持的方法,此外可以通过其它方法获取查询结果,参考 API章节

注意:不能使用 Illuminate\Database\Query\Builder 中的 getfirstfindpaginatecount 等方法

查询服务类

继承 DBQueryService,实现 connection 方法后在类中使用 statement 方法进行查询。这种方式能方便的组织和管理原生的查询语句

API

Queries

get(): \Illuminate\Support\Collection

获取列表,结果是一个二维数组集合类

find(mixed $default = null): mixed

获取单条数据,结果是一个一维数组,类似 Illuminate\Database\Eloquent\Builder 中的 find 方法

first(mixed $default = null): mixed

find 方法的别名

value(string $column, mixed $default = null): mixed

获取第一行某一列的值

pluck(string $column): \Illuminate\Support\Collection

获取某一列

exists(): bool

判断是否存在数据

ENV

YDQ_CACHE_ENABLED

是否开启查询缓存,默认关闭

YDQ_CACHE_DRIVER

缓存驱动,默认与 cache.default 保持一致

使用建议

License

MIT


All versions of laravel-db-query with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1.0
laravel/framework Version ^9.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package yesccx/laravel-db-query contains the following files

Loading the files please wait ....