az26 / db
There is no license information available for the latest version (v0.3.1) of this package.
database class
v0.3.1
2023-07-10 02:14 UTC
Requires
- php: >=7.0.0
- ext-pdo: *
README
use Az26\Util\Db;
require_once '../vendor/autoload.php';
$conf = [
'driver' => 'mysql',
'host' => 'localhost',
'port' => '3306',
'name' => 'test',
'user' => 'root',
'pass' => 'phpts',
'char' => 'utf8',
];
$db = new Db($conf);
$row = $db->fetchOne("select * from posts limit 1");
vd($db->getSql('posts', $row));
vd($db->getSql('posts', $row, [], 'pgsql'));
vd($row);
batch insert
$rows = [
['name' => 'dd', 'sex' => 'f', 'age' => 12],
['name' => 'aa', 'sex' => 'm', 'age' => 12]
];
$db->table('users')->insert($rows);
batch update
$rows = [
['name' => 'dd', 'sex' => 'f', 'id' => 1],
['name' => 'aa', 'sex' => 'm', 'id' => 2]
];
$db->table('users')->update($rows, 'id');
pluck
$db->table('users')->order('id', 'desc')->limit(2)->pluck('name', 'id');
1# array (
19 => 'aa',
18 => 'dd',
)