Download the PHP package lys/php-sharding-pdo without Composer

On this page you can find all versions of the php package lys/php-sharding-pdo. 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 php-sharding-pdo

PHP-Sharding-PDO

PHP、MySQL分库分表中间件,需要依赖PDO,PHP分库分表,支持协程

目录

环境要求

You can install the package via composer:

说明

(1)已支持协程,使用协程必须在主进程开启 \Swoole\Runtime::enableCoroutine();
(2)支持分片规则自定义,支持实现复杂的分片,分片规则是依赖输入的where条件或者insert插入的数据来的
(3)如果是insert匹配了多个库或者多张表就会返回false,请确认你insert插入匹配的规则只会有一个库和一张表
(4)由于MySQL不能使用滚动游标

规则匹配到多库多表分页会比较慢,优化的方案是使用一个where条件来过滤掉非必要的查询结果集,增加查询分页效率比如 where id >= 1000000 或者 where id <= 1000000

规则匹配到单库单表分页与原来的速度一样

(5)在事务处理中同时插入更新二个库或者多个库,是有一定机率(2PC提交)由于事务提交失败而导致数据不一致的,所以建议把某个维度的数据放在同一个数据库,或使用柔性事务,达到最终一致性

注意

(1)协程模式必须在主进程开启这个东西,否则会出现死锁
(2)协程中不能使用pdo长连接,在高并发的情况下,会出现如下异常
(3)Replace into自增主键,并发量大的时候可能出现返回false和死锁的,所以不适合高并发项目的使用,高并发,请使用雪花算法等一些分布式主键方案
(4)非协程情况下,并且常驻内存,如workerman框架请使用如下代码释放上下文,上下文管理为单例,所以需要该方法释放单例实例,一般是在一个请求结束,或者一个任务结束,释放完上下文,请重新new Model实例才行,因为释放上下文,清理了上下文中的PDO实例,方法如下:
(5) 请使用当前最新版本

单元测试

(1)先要配置tests/Config/.env ,测试环境数据库连接

.env文件

(2)然后执行如下脚本

非协程

协程

分表分库的知识可以参考这篇文章

https://blog.csdn.net/weixin_38642740/article/details/81448762

示例

详细请看tests目录

1.我们需要配置一下基本的分块规则配置类

2.Model创建

3.基础用法

查询

插入

更新

删除

4.Join用法

Join只支持同个数据库的,不支持跨库

5.XA用法

案例

https://www.what.pub/

License

Apache-2.0

更多请关注本人的博客

https://www.developzhe.com

关于项目

如果对您有所帮助或者觉得还不错,请点个Star支持一波

参与贡献

1.可以直接fork修改然后提交合并请求

2.如果有更好的意见或者方法欢迎私下交流

联系我 (Contact WeChat)

微信

有需要可以加我微信

Page visitor counter

visitor counter


All versions of php-sharding-pdo with dependencies

PHP Build Version
Package Version
Requires php Version >=7.2
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 lys/php-sharding-pdo contains the following files

Loading the files please wait ....