易截截图软件、单文件、免安装、纯绿色、仅160KB

php数据库导出类 导出JSON,XML,WORD,EXCEL

from:http://www.xland.com.cn/article/7/81/0804/28778.htm
本类实现:
数据库信息导出:word,excel,json,xml,sql
数据库恢复:从sql,从文件
具体用法:
首先新建测试用数据库mytest,然后在里面建张表
PHP代码:
以下是代码片段:
--
-- 表的结构 `test`
--
CREATE TABLE `test` (
   `id` int(11) NOT NULL auto_increment,
   `name` varchar(100) NOT NULL,
   `email` varchar(200) NOT NULL,
   `age` int(3) NOT NULL,
   PRIMARY KEY   (`id`)
) ENGINE=MyISAM   DEFAULT CHARSET=utf8 AUTO_INCREMENT=3 ;
--
-- 导出表中的数据 `test`
--
INSERT INTO `test` (`id`, `name`, `email`, `age`) VALUES
(1, 'pjq518', [email=]'pjq518@126.com'[/email], 22),
(2, 'xiaoyu', [email=]'xiaoyu@126.com'[/email], 21);
1.导出ext能方便调用的json
PHP代码:
以下是代码片段:
 $db=new db();
echo  $db->toExtJson('test');
//输出结果为
//{'totalCount':'2','rows':[{'id':'1','name':'pjq518','email':'pjq518@126.com','age':'22'},{'id':'2','name':'xiaoyu','email':'xiaoyu@126.com','age':'21'}]}
toExtJson( $table, $start="0", $limit="10", $cons="")有4个参数, $table为表名, $cons为条件,可以为string或array
2导出xml
PHP代码:
以下是代码片段:
 $db=new db();
echo  $db->toExtXml('test');
//输出结果

3导出excel和word
PHP代码:
以下是代码片段:
 $db=new db();
//toExcel
 $map=array('No','Name','Email','Age');//表头
 $db->toExcel('test', $map,'档案');
//导出word表格
// $db->toWord('test', $map,'档案');
//效果如下图
excel.JPG (27.04 KB)
2008-4-19 11:09

PHP代码:
以下是代码片段:
<?php
class Db
{
var  $conn;
function Db( $host="localhost", $user="root", $pass="", $db="mytest")
{
   if(! $this->conn=mysql_connect( $host, $user, $pass))
   die("can't connect to mysql sever");
   mysql_select_db( $db,&ensp


相关文档:

现在转行PHP啦,唉真的要术业有专攻啊

转眼间三年过去了,发觉自己都还在原地踏步,俗话说“逆水行舟,不进则退”;三年间,从asp,java到PHP,在几门语言之间辗转,
每门都会那么一点点,就是不精通,感觉每样都那不错手,现在下定决心未来很长一段时间内都将分配给PHP,一切就从Zend Framework框架开始吧 ......

DataSet XMl DateTable 互转

/// <summary>
/// DataTable-------------------->XML --String
/// </summary>
public static String ToXmlString(DataTable dt)
{
StringWriter tr = new StringWriter();
try
{
dt.WriteXml(tr); ......

php基本知识

1.php数组基础:
<?php
$ary2 = "zqhung_hongzequan_zqhong";
$arr3 =explode("_",$ary2);//拆分字符串
echo $arr3[1];//打印出来的结果是hongzequan
$ary1 = array("aa","bb");
$ary1[0]="zqhung";//修改数组中的值
echo $ary1[0],"<br>";//打印出来的结果是zqhung
$ary3 = array("id"=>55);
......

php开发web程序的几点经验记录

以前把php当作一个纯粹的系统编程脚本,从3月份开始第一次使用php写web网站,一点经验在这里总结一下。
一:打开错误显示和错误日志。在php.ini中把dispaly_errors设置为On,或者在脚本开头用ini_set('display_errors', 'On')。
二:
调试工具必备。需要两种调试工具:第一种是调试php脚本的,就像C调试器那样可以在脚本 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号