<?php
/* NOTE 必须安装pear.php文件
*/
ini_set('include_path',dirname($_SERVER["SCRIPT_FILENAME"])."/include");
//require_once 'common.php';
require_once 'DB.php';
require_once 'PEAR.php';
require_once ('xajaxGrid.inc.php');
//include "../include/config.inc.php";
//$new=new db_test();
//$new->Password;
// 连接数据库的用户名密码
$pass='root';
$pass='';
$database='test';
define('SQLC', "mysql://".$user.":".$pass."@localhost/".$database);
//define('SQLC', "mysql://".$DB_test->User.":".$DB_test->Password."@localhost/test");
$GLOBALS['db'] =& DB::connect(SQLC);
$GLOBALS['db']->setFetchMode(DB_FETCHMODE_ASSOC);
/** Factoty Class
*
* @author cd_wei <cd_wei@wintop2000.com>
* @version 2.0
* @date 2007 911
*/
class Factoty extends PEAR
{
var $table; //数据库中的表名,暂时不支持多表查询
var $f_names; //字段列表
var $f_shows; //字段列表
var $fd_id; //数据库中唯一(主键)的字段
var $f_replace_fields; //需要将值进行替换的字段
var $f_replace_values; //替换的值
var $f_require_names; //添加和编辑表单需要验证的字段列表
var $f_add_edit_names; //添加和编辑表单的字段
var $insert_field;
var $f_add_edit_type;
var $add_edit_table;
var $where;
var $f_sum_name;
var $readonly;
var $can_add;
var $can_edit;
var $can_delete;
/**
* 构造函数
*/
function Factoty($table,
$add_edit_table,
$f_names,
$f_shows,
$f_add_edit_names,
$f_id,
$f_replace_fields,
$f_replace_values,
$f_require_names,
$insert_field,
$f_add_edit_type,
$where,
$f_sum_name){
$this->table=$table;
$this->f_names=$f_names;
$this->f_shows=$f_shows;
$this->fd_id=$f_id;
$this->f_replace_fields=$f_replace_fields;
$this->f_replace_values=$f_replace_values;
$this->f_require_names=$f_require_names;
$this->f_add_edit_names=$f_add_edit_names;
$this->insert_field=$insert_field;
$this->f_add_edit_type=$f_add_edit_type;
$this->add_edit_table=$add_edit_table;
$this->where =$where;
$this->f_sum_name=$f_sum_name;
}
/**
* 返回所有记录
* @param $table (string) 需要进行查询的表
* @param $start (int) 要获得的起始记录序号
* @param $limit (int) 要获得的结束记录序号
* @param $order (string) 如何排序.
* @return $res (object) 返回一个object的数据集
*/
function &getAllRecords($start,$where, $limit, $order = null){
global $db;
$f_names=array();
$f_names=$this->f_names;
$sql = "SELECT $this->fd_id ,";
$sum=count($f_names);
for($i=0;$i<$sum;$i++){
if($i==0){
$sql.=" ".$f_names[$i]." ";
}else{
$sql.=" ,".$f_names[$i]." ";
}
}
if($order == null){
$sql.=" FROM $this->table ".$where." LIMIT $start, $limit ".$_SESSION['ordering'];
}else{
$sql.=" FROM $this->table ".$where." ORDER BY $order ".$_SESSION['ordering']." LIMIT $start, $limit ";
}
Factoty::events('QUERY SQL:::::'.$sql);
$res =& $db->query($sql);
return $res;
}
/**
* 通过条件进行查询返回记录
* @param $table (string) 需要进行查询的表
* @param $start (int) 要获得的起始记录
* @param $limit (int) 要获得的结束记录序号.
* @param $filter (string) 查询条件的字段名
* @param $content (string) 查询内容
* @param $order (string) 如何排序
* @return $res (object) 返回的结果集
*/
function &getRecordsFiltered($start, $where,$limit, $filter = null, $content = null, $order = null, $ordering = ""){
global $db;
$f_names=array();
$f_names=$this->f_names;
$sql = "SELECT $this->fd_id ,";
$sum=count($f_names);
for($i=0;$i<$sum;$i++){
if($i==0){
$sql.=" ".$f_names[$i]." ";
}else{
$sql.=" ,".$f_names[$i]." ";
}
}
//过滤危险字符
$content=& Factoty::saleChar($content);
if(($filter != null) and ($content != null)){
if($where==null || empty($where) || $where==""){
$where=" WHERE ";
}else{
$where.=" AND ";
}
$sql.= " FROM $this->table "
.$where.$filter." like '%".$content."%' "
." ORDER BY ".$order
." ".$_SESSION['ordering']
." LIMIT $start, $limit $ordering";
}else{
$sql.= " FROM $this->table ";
}
Factoty::events('过滤的SQL:'.$sql);
$res =& $db->query($sql);
return $res;
}
/**
* 获得表中记录总数
*
* @param $filter (string) 查询字段
* @param $order (string) 排序
* @return $row['numrows'] (int)
*/
function &getNumRows($where){
global $db;
$sql = "SELECT COUNT(*) AS numRows FROM $this->table ".$where;
Factoty::events("获得总数的SQL语句: ".$sql);
$res =& $db->getOne($sql);
return $res;
}
/**
* 获得某一字段的总和
*
* @param $f_sum_name (string) 查询字段
* @param $where (string) 查询条件
* @return $row['numrows'] (int)
*/
function getSumRows(){
global $db;
$f_sum_name=$this->f_sum_name;
if($f_sum_name==null){
return 0.00;
}
$sum=0.00;
$row=array();
$sql = "SELECT ".$f_sum_name." AS sumRows FROM $this->table ".$this->where;
$res =& $db->query($sql);
if($res->fetchInto($row)) {
$sum=$row['sumRows'];
}
return $sum;
}
/**
* 获得表中记录总数
*
* @param $filter (string) 查询字段
* @param $order (string) 排序
* @return $row['numrows'] (int)
*/
function &getNumRowsFilter($filter = null,$where, $content = null){
global $db;
$content=& Factoty::saleChar($content);
if($where==null || empty($where) || $where==""){
$where=" WHERE ";
} else{
$where.=" AND ";
}
$sql = "SELECT COUNT(*) AS numRows FROM $this->table ".$where;
if(($filter != null) and ($content != null)){
$sql = "SELECT COUNT(*) AS numRows "
."FROM $this->table "
.$where.$filter." like '%$content%'";
}
Factoty::events('11'.$sql);
$res =& $db->getOne($sql);
return $res;
}
function &getRecordByID($id){
global $db;
$id=& Factoty::saleChar($id);
没有合适的资源?快使用搜索试试~ 我知道了~
FragGridMaker For PHP
共39个文件
php:10个
ssk:7个
db:4个
需积分: 0 12 下载量 18 浏览量
2007-10-08
17:21:13
上传
评论
收藏 1.43MB RAR 举报
温馨提示
PHP代码生成器
资源详情
资源评论
资源推荐
收起资源包目录
OK.rar (39个子文件)
OK
out
include
DB
common.php 68KB
mysql.php 32KB
xajaxGrid.inc.php 20KB
PEAR.php 32KB
xajax.inc.php 52KB
xajax_js
CVS
Entries 105B
Repository 27B
Root 61B
time.js 7KB
xajax_uncompressed.js 22KB
xajax.js 16KB
DB.php 38KB
factotry.inc.php 3.9MB
browse1.js 966B
server.inc.php 15KB
xajaxCompress.php 5KB
xajaxResponse.inc.php 19KB
welcome.swf 11KB
login.swf 84KB
Grid.exe 1.71MB
images
bg1.JPG 1KB
Thumbs.db 15KB
dw_003_s.jpg 58KB
frag.JPG 11KB
libmySQL.dll 228KB
Skins
Diamond
DiamondBlue.ssk 16KB
DiamondGreen.ssk 16KB
WinXP
XPGreen.ssk 16KB
XPBlue.ssk 13KB
Thumbs.db 19KB
MP10
MP10.lnk 452B
mp10.gif 47KB
Thumbs.db 6KB
MP10.ssk 16KB
Vista2
vista2_color7.gif 25KB
vista2_color6.gif 24KB
Vista2_color6.ssk 16KB
Vista2_color7.ssk 16KB
Thumbs.db 30KB
共 39 条
- 1
79720699
- 粉丝: 90
- 资源: 7
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0