一个数据库查询构建器,旨在通过最小化代码中使用原始SQL来美化代码。NoQuery目前支持MySQL、Firebird & Interbase、PostgreSQL、SQLite3、Oracle、Microsoft SQL Server、Foxpro ODBC、Access ODBC、Informix、DB2、Sybase、Sybase SQL Anywhere、通用ODBC和Microsoft的ADO。

v1.1.0 2018-08-18 20:12 UTC

This package is not auto-updated.

Last update: 2024-09-25 22:38:47 UTC


README

NoQuery是一个基于ADODB库运行的php查询构建器。它的目的是通过减少代码量来简化数据库交互。由于利用了ADODB,NoQuery目前支持MySQL、Firebird-Interbase、PostgreSQL、SQLite3、Oracle、Microsoft SQL Server、Foxpro ODBC、Access ODBC、Informix、DB2、Sybase、Sybase SQL Anywhere、通用ODBC和Microsoft的ADO。

安装

 > composer require chamamme/noquery

配置

NoQuery requires a configuration array. A typical configuration looks like
	
	 $config = [
	        'driver' 	=> 'mysqli', #eg. access,ado,ibase,fbsql,db2,informix,ldap,mssqlnative,netezza,odbc,odbtp,oci8,pdo,postgres9,proxy,ads,sybase_ase,sqlite3,sybase

		'server' 	=> "localhost",

		'username' 	=> "root",

		'password' 	=> "",

		'port' 		=> "3306",

		'database' 	=> "test_db",

		'debug' 	=> false

	];

使用

一切从一个Tablet类的实例开始,它需要一个配置数组变量。

$db = new  NoQuery\Builder( $config ) 

现在我们已经准备好与我们的数据库进行交互了。

方法

示例

require("vendor/autoload.php"); #change to the actual path of your composer autoload.php file

use NoQuery\Builder;

$config = [
       'driver' 	=> "mysqli",
   	'server' 	=> "localhost",
   	'username' 	=> "root",
   	'password' 	=> "",
   	'port' 		=> "3306",
   	'database' 	=> "test_db",
   	'debug' 	=> false
   ];
   
   $db = new Builder( $config ) ; #Instantiate the Builder class
   
   #select query
   $db->table('users')
   	->select(['name','gender','age'])
   	->get();
   	
   #update statement
   $db->table('users')
   	  ->update(['name'=>'Chamamme'])
   	  ->where(["id = 5","gender ='male'"])
   	  ->go();