PHP module Reference, php_php tutorial

Source: Internet
Author: User
Tags dsn

PHP module Reference, PHP


 1 
    php 
 2 //Database Connection Classes3 classconndb{4     5     var $dbtype;6     var $host;7     var $user;8     var $pwd;9     var $dbname;Ten      One     //Construction Method A     functionCONNDB ($dbtype,$host,$user,$pwd,$dbname){ -         $this->dbtype=$dbtype; -         $this->host=$host; the         $this->user=$user; -         $this->pwd=$pwd; -         $this->dbname=$dbname; -     } +  -     //Implementing a connection to a database and returning a connection object +     functionGetconnid () { A           at         if($this->dbtype== "MySQL" | |$this->dbtype== "MSSQL"){ -             $dsn="$this->dbtype:host=$this->host;dbname=$this->dbname "; -}Else{ -             $dsn="$this->dbtype:dbname=$this->dbname "; -         }     -         Try { in             $conn=NewPDO ($dsn,$this->user,$this->PWD);//Initializes a PDO object, which is the creation of a database connection object $pdo -             $conn->query ("Set Names UTF8"); to             return $conn; +}Catch(pdoexception$e) { -              die("error!:".)$e->getmessage (). "
"); the } * $ Panax Notoginseng } - } the + //Database Management Classes A classadmindb{ the + - functionExecsql ($sqlstr,$conn){ $ $ $sqltype=Strtolower(substr(Trim($sqlstr), 0,6)); - $rs=$conn->prepare ($sqlstr);//Preparing query Statements - $rs->execute ();//executes a query statement and returns a result set the if($sqltype= = "Select"){ - $array=$rs->fetchall (PDO::FETCH_ASSOC);//get all the data in the result setWuyi if(Count($array) ==0 | |$rs==false) the return false; - Else Wu return $array; -}ElseIf($sqltype= = "Update" | |$sqltype= = "Insert" | |$sqltype= = "Delete"){ About if($rs) $ return true; - Else - return false; - } A } + } the //Pagination Class - classseppage{ $ var $rs; the var $pagesize; the var $nowpage; the var $array; the var $conn; - var $sqlstr; in functionShowData ($sqlstr,$conn,$pagesize,$nowpage){//Defining Methods the if(!isset($nowpage) ||$nowpage=="")//determines whether the variable value is empty the $this->nowpage=1;//define the Start page per page About Else the $this->nowpage=$nowpage; the $this->pagesize=$pagesize;//define the number of records per page output the $this->conn=$conn;//identity returned by the connection database + $this->sqlstr=$sqlstr;//the query statement executed - $offset=($this->NOWPAGE-1) *$this-pagesize; the $sql=$this->sqlstr. "Limit$offset,$this->pagesize ";Bayi $result=$this->conn->prepare ($sql);//Preparing query Statements the $result->execute ();//executes a query statement and returns a result set the $this-Array=$result->fetchall (PDO::FETCH_ASSOC);//get all the data in the result set - if(Count($this-Array) ==0 | |$this-Array==false) - return false; the Else the return $this-Array; the } the - functionShowPage ($contentname,$utits,$anothersearchstr,$anothersearchstrs,$class){ the $str=""; the $res=$this->conn->prepare ($this->SQLSTR);//Preparing query Statements the $res->execute ();//executes a query statement and returns a result set94 $this-Array=$res->fetchall (PDO::FETCH_ASSOC);//get all the data in the result set the $record=Count($this-Array);//Total Statistics Records the the $pagecount=Ceil($record/$this->pagesize);//calculate a total of several pages98 $str.=$contentname." ".$record." ".$utits. "Per page".$this->pagesize. " ".$utits. "No.".$this->nowpage. "Page/Total".$pagecount. "Page"; About $str.=" "; - if($this->nowpage!=1)101 $str. = "$_server[' Php_self ']. "? Page=1&page_type= ".$anothersearchstr." &parameter2= ".$anothersearchstrs. "Class=".$class." > Home ";102 Else103 $str. = "Home";104 $str.=" "; the if($this->nowpage!=1)106 $str. = "$_server[' Php_self ']. "? Page= ". ($this->nowpage-1). " &page_type= ".$anothersearchstr." &parameter2= ".$anothersearchstrs. "Class=".$class." > Previous Page ";107 Else108 $str. = "Prev";109 $str.=" "; the if($this->nowpage!=$pagecount)111 $str. = "$_server[' Php_self ']. "? Page= ". ($this->nowpage+1). " &page_type= ".$anothersearchstr." &parameter2= ".$anothersearchstrs. "Class=".$class." > Next Page "; the Else113 $str. = "Next Page"; the $str.=" "; the if($this->nowpage!=$pagecount) the $str. = "$_server[' Php_self ']. "? Page= ".$pagecount." &page_type= ".$anothersearchstr." &parameter2= ".$anothersearchstrs. "Class=".$class." > Last ";117 Else118 $str. = "Last";119 if(Count($this-Array) ==0 | |$this-Array==false) - return"No Data!" ";121 Else122 return $str; 123 }124 } the //System common Methods126 classusefun{127 - functionUnhtml ($text){129 $content=(NL2BR(Htmlspecialchars($text))); the $content=Str_replace("[Strong]", "",$content); 131 $content=str_replace("[/strong]", " ",$content); the $content=Str_replace("[em]", "",$content); 133 $content=str_replace("[/em]", " ",$content);134 $content=Str_replace("[U]", "",$content); 135 $content=str_replace("[/U]", " ",$content);136 137 138 $content=Str_replace("[Font color= #FF0000]", "",$content);139 $content=Str_replace("[Font color= #00FF00]", "",$content); $ $content=Str_replace("[Font color= #0000FF]", "",$content);141 142 $content=Str_replace("[Font face= Italic _gb2312]", "",$content);143 $content=Str_replace("[Font face= Arial]", "",$content);144 $content=Str_replace("[Font face= script]", "",$content);145 $content=Str_replace("[/font]", "",$content);146 //$content =str_replace (CHR), "", $content);147 $content=Str_replace("[Font size=1]", "",$content);148 $content=Str_replace("[Font size=2]", "",$content);149 $content=Str_replace("[Font size=3]", "",$content); Max $content=Str_replace("[Font size=4]", "",$content);151 $content=Str_replace("[Font size=5]", "",$content); the $content=Str_replace("[Font size=6]", "",$content);153 154 $content=Str_replace("[Fieldset][legend]", " ",$content); 155 $content=str_replace("[/legend]", " ", $content ); 156 $content= str_replace("[/fieldset]", " ",$content);157 return $content;158 }159 the }161 162?>


Q. What are some of the more popular modules in PHP?

Say module .... I too understand, because PHP module PHP environment concept, PHP environment by a multi-module, module for PHP implementation of certain functions, compared to the GD library, used to achieve picture operation.

I think say code block, or refer to reuse code, find PHP class to www.phpclasses.org, the official has 2 projects, called pear, also called pecl, which provides a lot of functional support, as well as brothers have been introduced, I suggest to see zendframework.

How do I use PHP modules already? Is it added to a webpage?

Message Board Source code replication web directory than the BBS directory home page and link BBS directory under the message program line

http://www.bkjia.com/PHPjc/827940.html www.bkjia.com true http://www.bkjia.com/PHPjc/827940.html techarticle PHP Module Reference, PHP 1? PHP 2//Database connection Class 3 class conndb{4 5 var $dbtype; 6 var $host; 7 var $user; 8 var $pwd; 9 var $dbna Me; 10 11//Construction Method-function C ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.