代码如下 | 复制代码 |
$pg=@pg_connect("host=localhost user=postgres password=sa dbname=employes") //$query="insert into employes values(10008,'susan','1985-09-04','80','50')"; //实例一[pg_fetch_row] for($i=0;$i<pg_num_rows($result);$i++) $row=@pg_fetch_row($result) or die("can't fetch row from table."); } //实例二[pg_fetch_array] //增加,删除,修改实例 |
代码如下 | 复制代码 |
<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <body> while ($row = mysql_fetch_array($result, mysql_both)) {// 取一条数据 mysql_free_result($result); ?> |
本款php连接mysql数据库连接程序代码是一款比较简单实用的连接代码,希望本教程对各位同学会有所帮助哦。
代码如下 | 复制代码 |
class mysql { public $last_query = ''; private $connection; public function __construct() {} public function __destruct() { //+======================================================+ $this->connection = mysql_connect($this->sqlserver, $this->sqluser, $this->sqlpassword); //demo // update query // select with check for record amount if ($db->hasresults("select * from userinfo")) { |
代码如下 | 复制代码 |
$fname = $_files['myfile']['name']; $do = copy($_files['myfile']['tmp_name'],$fname); if ($do){ echo"导入数据成功<br>"; }else{ echo ""; } |
代码如下 | 复制代码 |
error_reporting(0);// 导入csv格式的文件 ?> |
代码如下 | 复制代码 |
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");
*/