vectorface/mysqlite 问题修复 & 功能扩展

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

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

vectorface/mysqlite

最新稳定版本:v0.2.1

Composer 安装命令:

composer require --dev vectorface/mysqlite

包简介

Select MySQL compatibility functions for PDO's SQLite driver

README 文档

README

Build Status Code Coverage

MySQLite is an easy way to add MySQL functions to SQLite accessed through PDO. This can be useful for testing and development where an SQLite database may be more practical than a real MySQL database.

Usage

Using MySQLite is meant to be a one-step affair, with no configuration required:

use Vectorface\MySQLite\MySQLite;

// Create a PDO instance on an SQLite database
$pdo = new PDO('sqlite::memory:');

// Create compatibility functions for use within that database connection.
MySQLite::createFunctions($pdo);

// Use it.
$three = $pdo->query("SELECT BIT_OR(1, 2)")->fetch(PDO::FETCH_COLUMN);
// Wait... That works now?!? What the what?!?

It is also possible to use it as a one-liner:

$pdo = MySQLite::createFunctions(new PDO('sqlite::memory:'));

You can get a list of supported functions with MySQLite::getFunctionList().

Limitations

MySQLite only provides a limited subset of MySQL functions. There are a lot of MySQL functions, so there's both a developer cost and performance penalty to adding them all.

If you want to add more, it's easy. You only need to add a function called mysql_[function name] into one of the traits in src/Vectorface/MySQLite/MySQL.

For example, to create a function FOO() with silly behavior in String.php:

	...
	public static function mysql_foo($foo)
	{
		if ($foo == "foo") {
			return "bar";
		}
		return $foo;
	}
	...

With the above definition present, String::mysql_foo will automatically be registered with MySQLite::createFunctions($pdo) is used.

统计信息

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

GitHub 信息

  • Stars: 36
  • Watchers: 12
  • Forks: 7
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-12-24