定制 philwaters/database 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

philwaters/database

Composer 安装命令:

composer require philwaters/database

包简介

Simple database interface with row iterator

README 文档

README

Simple database interface with row iterator.

Examples

Instantiation

$database = new Database($connection);

Query

To select a row from table.

$query =
    "SELECT col1
       FROM table
      WHERE id = :col2_value";
$params = array(
    "id" => 123
);
$rows = $database->query($query);

To insert a row into table.

$query =
    "INSERT INTO table
               ( col1 )
        VALUES ( :col1_value,
                 :col2_value )";
$params = array(
    "col1_value" => "foo",
    "col2_value" => "bar"
);
$database->query($query, $params);

Truncating Tables

To truncate table.

$database->truncate("table");

Transactions

Using database transactions.

$database->beginTransaction();
$database->query(...);

if (isOK()) {
    $database->commit();
} else {
    $database->rollback();
}

Renaming Tables

Renaming old_name to new_name.

$database->renameTable("old_name", "new_name");

Swapping Tables

Swapping table_working with table_live. This can be useful when updating a working copy of a table then once complete swap it with the live table.

$database->swapTables("table_working", "table_live");

Iterating Rows

To iterate all selected rows using foreach.

$query =
    "SELECT a, b, c
       FROM table";
$rows = $database->query($query);

foreach ($rows as $row) {
    echo $row['a'];
}

Get All Rows

To get all rows as an array.

$rows = $database->query($query);

echo json_encode($rows->all);

Row Count

To get the number of rows selected.

$rows = $database->query($query);

echo count($rows);

Array Access

To access a specific row.

$rows = $database->query($query);

echo $row[7]['col'];

统计信息

  • 总下载量: 17
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-04-21

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固