rezon73 / pdo-clickhouse
专为ClickHouse设计的另一个Slim PDO数据库库
1.3.7
2021-02-02 00:30 UTC
Requires
- php: >=7.4.0
- ext-odbc: *
- ext-pdo: *
- rezon73/clickhouse-php-client: ^0.1.0
Requires (Dev)
- phan/phan: ^2.2
- phpunit/phpunit: ^8
- squizlabs/php_codesniffer: 3.*
README
另一个PDOClickHouse数据库库
安装
使用Composer
$ composer require rezon73/pdo-vertica
用法
选择、插入、更新和删除从或到users表的示例。
require_once 'vendor/autoload.php'; $hostname = '127.0.0.1'; $port = 8123; $pdo = new \Rezon73\PDOClickHouse\Database($hostname, $port); // SELECT * FROM users WHERE id = ? $selectStatement = $pdo->select() ->from('users') ->where('id', '=', 1234); $stmt = $selectStatement->execute(); $data = $stmt->fetch(); // INSERT INTO users ( id , usr , pwd ) VALUES ( ? , ? , ? ) $insertStatement = $pdo->insert(array( "id" =>1234, "usr" => "your_username", "pwd" => "your_password" )) ->into("users"); $insertStatement->execute(); // UPDATE users SET pwd = ? WHERE id = ? $updateStatement = $pdo->update(array("pwd" => "your_new_password")) ->table("users") ->where(new Clause\Conditional("id", "=", 1234)); $affectedRows = $updateStatement->execute(); // DELETE FROM users WHERE id = ? $deleteStatement = $pdo->delete() ->from("users") ->where(new Clause\Conditional("id", "=", 1234)); $affectedRows = $deleteStatement->execute();
当使用错误模式
PDOClickHouse::ERRMODE_EXCEPTION(默认)时,sqlsrv扩展将无法连接。要连接,您需要将array(PDOClickHouse::ATTR_ERRMODE => PDOClickHouse::ERRMODE_WARNING)(或PDOClickHouse::ERRMODE_SILENT)显式传递给构造函数,或者在sqlsrv中使用时覆盖getDefaultOptions()方法。
文档
见文档
变更日志
见变更日志
许可证
见许可证