ezsql mysql_ezSQL PHP数据库操作类库

ezSQL PHP数据库操作类库

2019-04-09 19:47:11来源:易采站长站作者:刘景俊

ezSQL 下载地址:

下载 : ezSQL

新版本是2.05添加了很多支持,包括 CodeIgniter,MSSQL, PDO 等等

我之前也为 CodeIgniter 写过一次,不过只支持 MySQL

看看使用示例

其实也没什么难度,直接看源代码即可,主要是程序设计的思想很好。

Example 1

----------------------------------------------------

// Select multiple records from the database and print them out..

$users = $db->get_results("SELECT name, email FROM users");

foreach ( $users as $user ) {

// Access data using object syntax

echo $user->name;

echo $user->email;

}

Example 2

----------------------------------------------------

// Get one row from the database and print it out..

$user = $db->get_row("SELECT name,email FROM users WHERE id = 2");

echo $user->name;

echo $user->email;

Example 3

----------------------------------------------------

// Get one variable from the database and print it out..

$var = $db->get_var("SELECT count(*) FROM users");

echo $var;

Example 4

----------------------------------------------------

// Insert into the database

$db->query("INSERT INTO users (id, name, email) VALUES (NULL,'justin','jv@foo.com')");

Example 5

----------------------------------------------------

// Update the database

$db->query("UPDATE users SET name = 'Justin' WHERE id = 2)");

Example 6

----------------------------------------------------

// Display last query and all associated results

$db->debug();

Example 7

----------------------------------------------------

// Display the structure and contents of any result(s) .. or any variable

$results = $db->get_results("SELECT name, email FROM users");

$db->vardump($results);

Example 8

----------------------------------------------------

// Get 'one column' (based on column index) and print it out..

$names = $db->get_col("SELECT name,email FROM users",0)

foreach ( $names as $name ) {

echo $name;

}

Example 9

----------------------------------------------------

// Same as above ‘but quicker'

foreach ( $db->get_col("SELECT name,email FROM users",0) as $name ) {

echo $name;

}

Example 10

----------------------------------------------------

// Map out the full schema of any given database and print it out..

$db->select("my_database");

foreach ( $db->get_col("SHOW TABLES",0) as $table_name ) {

$db->debug();

$db->get_results("DESC $table_name");

}

$db->debug();

EZSQL类介绍:

ezsql是一个小型的快速的数据库操作类,可以让你很容易地用PHP操作各种数据库( MySQL、oracle8/9 、interbase、FireBird、PostgreSQL、MS-SQL、sqlite、sqlite C++)。

在你的脚本开头是要包含一个一个PHP文件。然后,你就可以使用更小、更容易的一套ezsql函数来代替标准的PHP数据库函数。

热点聚合:

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值