limingxinleo / x-phalcon-db
Phalcon DB
Installs: 3 189
Dependents: 1
Suggesters: 0
Security: 0
Stars: 3
Watchers: 4
Forks: 0
Open Issues: 0
Requires
- php: >=5.6
- ext-phalcon: ^3.0
Requires (Dev)
- phalcon/dd: ^1.1
- phpunit/phpunit: >=5.6
Suggests
- php: >=7.0
This package is auto-updated.
Last update: 2024-10-17 20:04:54 UTC
README
安装
composer require limingxinleo/x-phalcon-db
使用
<?php use Phalcon\DI\FactoryDefault; use Phalcon\Db\Adapter\Pdo\Mysql; use PDO; use Xin\DB; // Your Method To Get DI; $di = new FactoryDefault(); $di->setShared('db', function () { return new Mysql( [ 'host' => '127.0.0.1', 'username' => 'root', 'password' => '910123', 'dbname' => 'phalcon', 'charset' => 'utf8', 'options' => [ PDO::ATTR_CASE => PDO::CASE_NATURAL, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::ATTR_ORACLE_NULLS => PDO::NULL_NATURAL, PDO::ATTR_STRINGIFY_FETCHES => false, PDO::ATTR_EMULATE_PREPARES => false, ], ] ); }); $sql = "SELECT * FROM `test` WHERE `name` = ? LIMIT 1;"; $res = DB::query($sql, ['limx']);