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

[PHP]PDO的使用

1. 安装php5.1以上的版本,有支持pdo!为了使你的环境能提供对pdo的支持!在php.ini文件加入以下:
extension=php_pdo.dll
extension=php_pdo_mysql.dll
extension=php_pdo_mssql.dll(支持mssql数据库)
2. 以下为PH中PDO的具体使用
 <?php
$dsn = 'mysql:dbname=MyDbName;host=localhost';
$user = 'root';
$password = '666666';
try {
$dbCon = new PDO($dsn, $user, $password);
} catch (PDOException $e) {
print 'Connection failed: '.$e->getMessage();
}
//------------pdo query example---------
$strSQL = "select * from Users";
//---------method1---------
try {
$result = $dbCon->query($strSQL);
if( $result ){
$uCol = $result ->columnCount();
$arRS = $result ->fetchAll();
foreach ($arRS as $row){
for( $i=0; $i<$uCol; $i++ )
print $row[$i]." ";
print "<br>";
}
}
}catch (PDOException $e) {
print $e->getMessage();
}

//---------method2---------
try {
$sth = $dbCon->prepare($strSQL);
$sth->execute();
$uCol = $sth->columnCount();

while($row = $sth->fetch()){
for( $i=0; $i<$uCol; $i++ )
print $row[$i]." ";
print "<br>";
}

$result = $sth->fetchAll();
foreach ($result as $row){
for( $i=0; $i<$uCol; $i++ )
print $row[$i]." ";
print "<br>";
}
}catch (PDOException $e) {
print $e->getMessage();
}
?>


相关文档:

PHP: How to Get the Current Page URL

Sometimes, you might want to get the current page URL that is shown
in the browser URL window. For example if you want to let your visitors
submit a blog post to Digg you need to get that same exact URL. There
are plenty of other reasons as well. Here is how you can do that.
Add the followin ......

php中iconv函数使用方法(转)


iconv函数库能够完成各种字符集间的转换,是php编程中不可缺少的基础函数库。 
1、下载libiconv函数库http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.9.2.tar.gz; 
2、解压缩tar -zxvf libiconv-1.9.2.tar.gz; 
3、安装libiconv 
#configure --prefix=/usr/local/iconv 
#make 
......

10款PHP开源电子商务系统


最近一年以来,站长界有一个趋势: 很多站长转型做电子商务,或利用现有的网站资源整合电子商务。一方面由于网站越来越难做,而同时在经济大环境的影响下,网上购物却越为越吃香。转做网商或是结合网络购物是个不错的主意。
要做电子商务,你可以选择在淘宝,拍拍,Ebay或是最新的百度有啊,而如果要自己搭建平台,当然首 ......

PHP 中长连接的实现

  每次我们访问 PHP 脚本的时候,都是当所有的PHP脚本执行完成后,我们才得到返回结果。如果我们需要一个脚本持续的运行,那么我们就要通过 PHP 长连接的方式,来达到运行目的。
  每个 PHP 脚本都限制了执行时间,所以我们需要通过 set_time_limit 来设置一个脚本的执行时间为无限长;然后使用 flush() 和 ob_flush() ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号