承接 dimns/simplepdo 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

dimns/simplepdo

Composer 安装命令:

composer require dimns/simplepdo

包简介

Simple PDO Wrapper class for MySQL and SQLite

README 文档

README

Simple PDO Wrapper class for MySQL and SQLite

Latest Stable Version Total Downloads License

Requirements

  • PHP 5.3 or higher is required.
  • PHP extension MySQL or SQLite.

Composer installation

  1. Get Composer.
  2. Require SimplePDO with php composer.phar require dimns/simplepdo or composer require dimns/simplepdo (if the composer is installed globally).
  3. Add the following to your application's main PHP file: require 'vendor/autoload.php';.

Usage

// Init class for MySQL (default port 3306)
$db = new DimNS\SimplePDO\MySQL('server', 'dbname', 'username', 'password');
// Or init class for MySQL (override port)
$db = new DimNS\SimplePDO\MySQL('server', 'dbname', 'username', 'password', 3307);
// Or init class for SQLite
$db = new DimNS\SimplePDO\SQLite('/path/to/database/file.sqlite');

// Query without prepared variables
$result = $db->query('SELECT `field1`, `field2` FROM `table`');
echo '<pre>';
print_r($result);
echo '</pre>';

// Query with prepared variables
$result = $db->query('INSERT INTO `table` SET
    `field1` = :field1,
    `field2` = :field2
', [
    'field1' => 'Simple string',
    'field2' => 123,
]);
echo $result;

// Transaction (only for mysql innodb table)
$result = $db->transaction([
    [
        'query' => 'INSERT INTO `table` SET `field1` = :field1, `field2` = :field2, `field3` = :field3',
        'data'  => [
            'field1' => 'val1',
            'field2' => 'val2',
            'field3' => 'val3',
        ],
    ], [
        'query' => 'UPDATE `table` SET `field1` = :field1 WHERE `field2` > :field2',
        'data'  => [
            'field1' => 'val1',
            'field2' => 'val2',
        ],
    ],
]);
echo '<pre>';
print_r($result);
echo '</pre>';

Return values

  1. For select and show returns an array containing all of the result set rows.
  2. For insert returns the ID of the inserted row.
  3. For all other queries returns the number of rows affected by the SQL statement.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-04-28

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固