apsxj/mysql
Composer 安装命令:
composer require apsxj/mysql
包简介
MySQL Library for APSXJ Server
README 文档
README
MySQL Library for APSXJ Server
Getting Started
- Add the following to your
composer.jsonfile:
"require": { "apsxj/mysql": "dev-main" }, "repositories": [ { "type": "git", "url": "https://github.com/apsxj/mysql.git" } ]
-
Run
composer install -
Before calling any of the methods, require the vendor autoloader
// For example, from the root directory... require_once(__DIR__ . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php');
- Extend the
Connectionclass
<?php class Connection extends \apsxj\mysql\Connection { public function __construct() { parent::__construct( 'localhost', 'test_db', 'test_user', 'supersecret' ); } } $connection = new Connection(); $rows = $connection->fetch("SELECT * FROM `test_table`;");
- Extend the
Tableclass
<?php use apsxj\mysql\Column; use apsxj\mysql\Type; class Table extends \apsxj\mysql\Table { public function __construct() { parent::__construct( new Connection(), 'test', array( new Column('id', Type::INT), new Column('created', Type::INT), new Column('updated', Type::INT), new Column('deleted', Type::BOOL), new Column('name') ) ); } public function insert($name) { $sql = "INSERT INTO `test` (`id`, `created`, `updated`, `deleted`, `name`) VALUES (NULL, ?, ?, 0, ?);"; $date = date('U'); $args = array($date, $date, $name); return $this->connection->insert($sql, $args); } } $table = new Table(); $table->insert('Test Name');
统计信息
- 总下载量: 9
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-05-10