Dbmier LED Artcraft Tracing Light Pad Light Box Light Board Light Table- A4

PHP Tech Blog

Dbmier LED Artcraft Tracing Light Pad Light Box Light Board Light Table- A4

留言簿(5)

Links

My Favorites

推荐技术文章

阅读排行榜

评论排行榜

WordPress中的数据库操作类wp-db.php

版权:转载
来源:互联网

WordPress中的数据库操作类wp-db.php的原型是ezSQL。官方网站: http://php.justinvincent.com
ezSQL支持对如下数据库的操作:mySQL / Oracle8/9 / InterBase/FireBird / PostgreSQL / MS-SQL / SQLite / SQLite c++.
不过在WordPress中只实现了对Mysql的操作功能。
在ezSQL的官方网站对其有如下描述:

·ezSQL is a widget that makes it very fast and easy for you to use database(s) within your PHP scripts ( mySQL / Oracle8/9 / InterBase/FireBird / PostgreSQL / MS-SQL / SQLite / SQLite c++).
·It is one php file that you include at the top of your script. Then, instead of using standard php database functions listed in the php manual, you use a much smaller (and easier) set of ezSQL  functions.
·It automatically caches query results and allows you to use easy to understand functions to manipulate and extract them without causing extra server overhead
·It has excellent debug functions making it lightning-fast to see what’s going on in your SQL code
·Most ezSQL functions can return results as Objects, Associative Arrays, or Numerical Arrays
·It can dramatically decrease development time and in most cases will streamline your code and make things run faster as well as making it very easy to debug and optimise your database queries.
·It is a small class and will not add very much overhead to your website.

ezSQL的官网:http://www.woyano.com/jv/ezsql
ezSQL的帮助文档(英)http://justinvincent.com/docs/ezsql/ez_sql_help.htm
ezSQL的论坛: http://www.jvmultimedia.com/portal/?q=forum
介绍ezSQL理论的相关文章: http://www.jvmultimedia.com/portal/node/14
ezSQL更新历史 http://justinvincent.com/docs/ezsql/readme.txt

使用ezSQL的站点:
    * www.reviewcast.com - Community review site
    * www.blbex.com - Big League Baseball Exchange
    * www.acaldra.com - Community site
    * www.okyz.com - French Mac, PC, Unix software company
    * www.WebspaceEnterprises.com - E-Business development company
    * www.polandguangzhou.com - Polish Consulate in China (Commercial and Economic Section)


WordPress数据驱动wpdb的分析
总的来说:wpdb的设计,简洁、灵活运用对象和数组,逻辑讲究

wpdb的方法的分析:
funciton wpdb($dbuser, $dbpassword, $dbname,$dbhost);
连接数据库!

function escape($string);
我猜是提供给整个wordpress使用,使用反斜线引用字符串,即使用魔术引号。

function print_error($str='’);
屏幕打印数据库驱动出现的错误。

function show_errors(); function hide_errors();
数据驱动错误是否屏幕打印的开关。

function flush();
清空查询结果缓存

function query($query);
方法query()返回值分二种情况,

1、”insert|delete|update|replace”, 返回受影响行数
2、“select”, 返回查询到的记录行数

“insert|replace”,用$this->insert_id记录新插入的ID

以$this->last_result记下查询结果集

记下sql语句查询所需时间
记下调用方法的详情 $this->func_call = “$db->query(\”$query\”)”;
可保存执行sql——$query和执行时间

function get_var($query=null, $x =0, $y=0);
从数据库取出一个值,关键词“一个”,精确的一个点。

function get_row($query=null, $output = OBJECT, $y = 0);
从查询结果集中取出一行。

function get_col($query = null, $x =0);
从查询结果集中取出一列。

function get_results($query = null, $output = Object);
返回查询结果集,可以以 OBJECT, ARRAY_A, ARRAY_N三种方式返回。

function get_col_info ($info_type = ‘name’, $col_offset = -1);
返回字段信息。有一个不惑,if ( $this->col_info ) { } 这句会造成没有返回结果,这个设计有何用途?

function timer_start(); function timer_stop();
测量执行时间的方法。

function bail($message);
用友好的方法打印信息。

wpdb的属性的设计:(待续)
var $show_errors = true;
var $num_queries = 0;
var $last_query;
var $col_info;
var $queries;

// Our tables
var $posts;
var $users;
var $categories;
var $post2cat;
var $comments;
var $links;
var $linkcategories;
var $options;
var $optiontypes;
var $optionvalues;
var $optiongroups;
var $optiongroup_options;
var $postmeta;

邀各位一起学习wordpress的优雅编码。


posted on 2009-08-14 16:40 haix 阅读(953) 评论(0)  编辑 收藏 引用 网摘 所属分类: Wordpress和开源


只有注册用户登录后才能发表评论。
网站导航:
Dbmier LED Artcraft Tracing Light Pad Light Box Light Board Light Table- A4