欢迎您访问我爱IT技术网,今天小编为你分享的编程技术是:【PHP面向对象编程快速入门】,下面是详细的分享!
PHP面向对象编程快速入门
class SQL
{
var $Driver; //实际操作的数据库驱动子类
var $connection; //共用的数据库连接变量
function DriverRegister($d)
{
if($d!="")
{
$include_path=ini_get("include_path");
$DriverFile=$include_path."/".$d.".php";
//驱动的存放路径必须在PHP.ini文件中设定的INCLUDE_PATH下
if( file_exists( $DriverFile)) //查找驱动是否存在
{
include($DriverFile);
$this->Driver=new $d();
// 根据驱动名称生成相应的数据库驱动类
return true;
}
}
return false; //注册驱动失败
}
function Connect($host,$user,$passwd,$database)//连接数据库的函数
{
$this->Driver->host=$host;
$this->Driver->user=$user;
$this->Driver->passwd=$pas
swd;
$this->Driver->database=$d
atabase;
$this->connection=$this->Driver->Connect();
}
function Close()//关闭数据库函数
{
$this->Driver->close($this->connection);
}
function Query($queryStr)//数据库字符串查询函数
{
return $this->Driver->query($queryStr,$this->connection);
}
function getRows($res)//查找行
{
return $this->Driver->getRows($res);
}
function getRowsNum($res)//取得行号
{
return $this->Driver-> getRowsNum ($res);
}
}
? >
以上所分享的是关于PHP面向对象编程快速入门,下面是编辑为你推荐的有价值的用户互动:
相关问题:学习PHP面向对象编程开发分为那几个阶段,从基础开...
答:如果想自己学的话,就可以先研究一下mvc,如果想快速使用,就可以下载一些网上有的cms >>详细
相关问题:PHP面向对象编程题
答:session_start(); /** * @author [scott] * @copyright 2010 */class member{ private $name = ''; private $email = ''; private $loginTime = ''; function __construct() { } function __destruct() { $this->logout(); } function login($na... >>详细
相关问题:在php中的面向对象编程问题?
答:举例说明: 例1,不带参数的: class test_class { //析构函数,参数列中不带参数,实例化类时也不带参数。 public function __construct () { echo "HELLO WORLD"; } } $obj = new test_class(); 输出:HELLO WORLD 例2,带有默认参数的: clas... >>详细
- 评论列表(网友评论仅供网友表达个人看法,并不表明本站同意其观点或证实其描述)
-
