代码如下 | 复制代码 |
class excel{ /** /** /** /** /** // initialize all cells for this row endforeach; // transform $cells content into one row } /** // run through the array and add them into rows } /** // strip out special chars first // now cut it to the allowed length // set title } /** // deliver header (as recommended in php manual) // print out document to the browser } } |
/**
* cakephp中使用方法
* 注意 ** cakephp 配置文件 define('debug', 0);
*
* vendor ('excel');
* $doc = array (
* 0 => array ('中国', '中国人', '中国人民', '123456');
* );
* $xls = new excel;
* $xls->addarray ( $doc );
* $xls->generatexml ("mytest");
*/
/**
* 非框架使用方法
*
* require_once('excel.php');
* $doc = array (
* 0 => array ('中国', '中国人', '中国人民', '123456');
* );
* $xls = new excel;
* $xls->addarray ( $doc );
* $xls->generatexml ("mytest");
*/
代码如下 | 复制代码 |
$fname = $_files['myfile']['name']; $do = copy($_files['myfile']['tmp_name'],$fname); if ($do){ echo"导入数据成功<br>"; }else{ echo ""; } |
代码如下 | 复制代码 |
error_reporting(0);// 导入csv格式的文件 ?> |
代码如下 | 复制代码 |
$conn = new com("adodb.connection"); $conn->open($connstr); |
/*
代码如下 | 复制代码 |
* created on 2010-4-21 //构造函数 进行初始化操作 /********************************************************************************************* //数据库连接 //错误信息 //mysql_query()方法 //echo $sql."<br/>";//测试完成后 注释 //sql语句显示 //mysql_affected_rows()方法 //mysql_result方法 //mysql_num_rows方法 //mysql_num_fields方法 //mysql_free_result方法 //mysql_insert_id方法 //mysql_fetch_row方法 //mysql_get_server_info方法 //mysql_fetch_array()方法 //mysql_close方法
/* function fn_insert($table,$fields,$values)
if($condition!="") if($order!="") if($limit!="") return $this->query($query);
return $this->query($sql);
|
//调用方法
代码如下 | 复制代码 |
$db = new mysql('127.0.0.1','username','password','databasename',"utf8"); |
//php教程.ini需要开放:
//extension=php_pdo.dll
//extension=php_pdo_odbc.dll
//数据库为acc.mdb,为防止恶意下载,改为acc.php
try{
$db = new pdo("odbc:driver={microsoft access driver (*.mdb)};dbq=".getcwd()."\acc.php",'aaa','123456'); //getcwd()函数是获取当前路径
//echo "connected ";
date_default_timezone_set('asia/shanghai'); //北京时间
$v="测试".date("y-m-d h:i:s")."添加的内容";
$db->exec("insert into table1(topic) values('$v')");//插入
//echo $db->lastinsertid(); //不支持
$rs=$db->query("select * from table1"); //选择
while($row=$rs->fetch()){
echo $row[id]."-".$row[topic]."<br>";
};
} catch (exception $e) {
//echo "failed:".$e->getmessage();
}