jelix/database
Composer 安装命令:
composer require jelix/database
包简介
Lightweight PHP abstraction layer to access and query SQL databases, with an API to inspect and modify databases schema.
README 文档
README
Lightweight PHP abstraction layer to access and query SQL databases.
It uses the dedicated PHP API for each database type it supports, not PDO. The API of connectors and result sets are almost the same as in PDO. There is an API to manipulate schemas.
It supports Mysql 8+, Postgresql 13+, Sqlite 3. It supports partially (Schema API not fully implemented) SQLServer 2012+ and OCI. There is a connector using PDO, so you can use other databases (except with the Schema API).
Compatible with PHP 8.2 to 8.5.
installation
You can install it from Composer. In your project:
composer require "jelix/database"
Usage
Quick start:
use \Jelix\Database\AccessParameters; use \Jelix\Database\Connection; // parameters to access to a database. they can come from a configuration file or else.. $parameters = array( 'driver'=>'sqlite3', "database"=>"/app/tests/units/tests.sqlite3", ); // verify content of parameters and prepare them for the Connection object. $accessParameters = new AccessParameters($parameters, array('charset'=>'UTF-8')); // then you can retrieve a connector $db = Connection::create($accessParameters); // let's insert some values $insertSql = "INSERT INTO ".$db->encloseName('myValues')." ( ".$db->encloseName('id'). ", ".$db->encloseName('value')." ) VALUES "; $value = 'foo'; // insert one value with a classical query $db->exec($insertSql." (1, ".$db->quote($value).")"); // insert one value with a prepared query $stmt = $db->prepare($insertSql."(:id, :val)"); $stmt->bindValue('id', 2, \PDO::PARAM_INT); $myVar = 'bar'; $stmt->bindParam('value', $myVar, \PDO::PARAM_STR); $stmt->execute(); // retrieve all records $resultSet = $db->query("SELECT id, value FROM myValues"); // records are always objects foreach ($resultSet as $record) { echo "id=".$record->id."\n"; echo "value=".$record->value."\n"; }
Full documentation: see the docs directory.
History
This library has been extracted from the Jelix framework 1.7, and it has been modernized.
jelix/database 适用场景与选型建议
jelix/database 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3.73k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2020 年 03 月 03 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「database」 「sql」 「mysql」 「schema」 「postgresql」 「sqlserver」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 jelix/database 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 jelix/database 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 jelix/database 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Dibi is Database Abstraction Library for PHP
Store your language lines in the database, yaml or other sources
A package for automatically encrypting and decrypting Eloquent attributes in Laravel 5.5+, based on configuration settings.
Query filtering in your frontend
A PSR-7 compatible library for making CRUD API endpoints
Database/ORM-agnostic query construction helper
统计信息
- 总下载量: 3.73k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 17
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: LGPL-2.1
- 更新时间: 2020-03-03