majenkotech/dbwrapper 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

majenkotech/dbwrapper

最新稳定版本:v0.2.1

Composer 安装命令:

composer require majenkotech/dbwrapper

包简介

Simple MySQL db wrapper functions using PDO

README 文档

README

This is a simple class for providing a simple API to the PDO MySQL database driver.

It relies on all tables in your database having a column called id which is typically a serial type (bigint(20) unsigned auto_increment). This column is used to select individual records within a table.

Usage

  1. Create an object:

    $db = new \Majenkotech\DB("username", "password", "hostname", "database");

  2. Execute a query with optional embedded arguments:

    $q = $db->query("SELECT name,size FROM something WHERE foo=:bar AND baz=:fod", array( "bar" => 23, "fod" => "beep" ) );

  3. Use $db->nextRecord($q) to get successive record objects:

    while ($r = $db->nextRecord($q)) { print "$r->name is $r->size\n"; }

Other useful functions

  • Insert a new record into a table:

    $id = $db->insert("tablename", array( "field1" => "value", "field2" => value, ... etc ... ));

  • Get ID of last inserted record:

    $id = $db->id();

  • Update a record in a table:

    $db->update("table", $id, array( "field1" => "value", "field2" => value, ... etc ... ));

  • Select a record by ID:

    $r = $db->select("tablename", $id);

  • Set a single value in a record in a table:

    $db->set("table", $id, "field", "value");

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: BSD3
  • 更新时间: 2018-01-04