geeshoe/dbclass

此包已被废弃且不再维护。作者建议使用 geeshoe/dblib 包。
此包的最新版本(0.3.0)没有可用的许可证信息。

使用 PDO 连接到 mysql 的 PHP 类

0.3.0 2018-03-22 18:06 UTC

This package is not auto-updated.

Last update: 2022-02-01 13:11:24 UTC


README

dbClass-php 已弃用。它已被 geeShoe/DbLib 替换

连接到 mysql 数据库的类,扩展了 PHP PDO 扩展。目标是自动化许多常见的 mySql 方法,以适应高度依赖 mysql 的项目。

请注意,此项目处于初始开发阶段,因此部分文档可能不完整。

入门

以下说明将帮助您在本地机器上运行项目副本,以便进行开发和测试。有关如何将项目部署到实时系统的说明,请参阅部署。

先决条件

项目的当前开发使用 PHP 7.2,但支持 mysql pdo 扩展的较早版本的 PHP 也将正常工作。要检查 PDO mysql 驱动是否启用,请在 CLI 中运行以下命令或在您的 webroot 中的一个页面中添加它

phpinfo();

并确保 PDO 驱动程序列表中有 mysql。如果没有或您在 phpinfo() 中找不到任何关于 PDO 的提及,您可能需要重新编译 PHP

./configure --with-pdo-mysql

安装

要将 DbClass 添加到您的项目,请运行

composer require geeshoe/dbclass

如果您希望使用 dbClass-php 的开发分支,请更改 composer.json 文件中的以下行代码。

composer require geeshoe/dbclass dev-develop

配置

将包含的 sample_config.ini 复制到您的 vendor 文件夹的父目录,并将其重命名为 DbConfig.ini。更改 mysql 部分的值以反映您的数据库配置。

将 AltPath 设置为 /some/other/path/config.ini 将使用指定配置文件中的配置指令,而不是 DbConfig.ini 中的指令。

[config]
AltPath =

[mysql]
hostName = 127.0.0.1   //Points to the mysql server. Usually 127.0.0.1 or localhost 
port = 3306   //Typically the mysql port is 3306
dataBase = dbClassTest   //The name of the database which you will be using.
userName = testUser   //Both the username and password for the mysql account used to manipulate the mysql database
passWord = me6wp3Ha92n

文档

API 在 docs/api/index.html 中进行了文档记录

@TODO - 提供如何使用该功能的示例。

作者

源代码可在 (https://github.com/geeshoe) 上找到

有关问题、评论或抱怨,请给我发邮件:

jr (at) geeshoe (dot) com