找回密码
 注册
广告投放 虚位以待【阿里云】2核2G云新老同享 99元/年,续费同价做网站就用糖果主机-sugarhosts.comJtti.com-新加坡服务器,美国服务器,香港服务器
查看: 882|回复: 10

哇咔咔,看了6个小时的php,偶现在看php代码好轻松啊

[复制链接]
发表于 2007 年 1 月 28 日 06:11:00 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?注册

×
哇咔咔,看了6个小时的php,偶现在看php代码好轻松啊
呵呵
还从代码中学到了一些东西。
呵呵,继续努力……
坚持能看明白别人的cms源码..........


另求:
那位个推荐个所见即所得编辑器?
Jgwy.Com - Free Web Hosting Guide & Directory In China since 2001! Jgwy.Net-Jglt.Net
 楼主| 发表于 2007 年 1 月 28 日 06:13:01 | 显示全部楼层
【腾讯云】2核2G云服务器新老同享 99元/年,续费同价
顺便帖链接mysql的一个类。
class mysql{       
        function connect($dbhost, $dbuser, $dbpw, $dbname = '',$dbcharset='') {       
            if(!@mysql_connect($dbhost, $dbuser, $dbpw)) {
                    $this->show('Can not connect to MySQL server');
                }       
                if($dbname) {
                        $this->select_db($dbname);
                }
                if($this->version() > '4.1') {
                    if($dbcharset) {                       
                         $this->query("SET NAMES '".$dbcharset."'");       
                    }
                }
        }

        function select_db($dbname) {
                return mysql_select_db($dbname);
        }

        function fetch_array($query, $result_type = MYSQL_ASSOC) {
                return @mysql_fetch_array($query, $result_type);
        }

        function query($sql, $type = '') {
            if(!($query = mysql_query($sql))) $this->show('MySQL Query Error', $sql);
            return $query;               
        }

        function affected_rows() {
                return mysql_affected_rows();
        }

        function result($query, $row) {
                return mysql_result($query, $row);
        }

        function num_rows($query) {
                return @mysql_num_rows($query);
        }

        function num_fields($query) {
                return mysql_num_fields($query);
        }

        function free_result($query) {
                return mysql_free_result($query);
        }

        function insert_id() {
                return mysql_insert_id();               
        }

        function fetch_row($query) {
                return mysql_fetch_row($query);
        }

        function version() {
                return mysql_get_server_info();
        }

        function close() {
                return mysql_close();
        }

        function show($message = '', $sql = '') {
                if(!$sql) echo $message;
                else echo $message.'<br>'.$sql;
        }
}
Jgwy.Com - Free Web Hosting Guide & Directory In China since 2001! Jgwy.Net-Jglt.Net
回复

使用道具 举报

 楼主| 发表于 2007 年 1 月 28 日 06:31:18 | 显示全部楼层
不过如果修改以下第一个function里的mysql_connect为mysql_pconnect则建立了连接池
也就说无需关闭链接了
这对于链接要求高的很有好处……
但mysql_close也无法关闭


偷偷说下
php有类,虽然和java还是有很大的不同,但我还是很喜欢,代码那个简洁儿啊……

[ 本帖最后由 大虫 于 2007-1-28 06:41 编辑 ]
Jgwy.Com - Free Web Hosting Guide & Directory In China since 2001! Jgwy.Net-Jglt.Net
回复

使用道具 举报

发表于 2007 年 1 月 28 日 08:06:32 | 显示全部楼层
函数好多。。。。。
Jgwy.Com - Free Web Hosting Guide & Directory In China since 2001! Jgwy.Net-Jglt.Net
回复

使用道具 举报

发表于 2007 年 1 月 28 日 08:13:53 | 显示全部楼层
class mysql{        
        function connect($dbhost, $dbuser, $dbpw, $dbname = '',$dbcharset='') {        
            if(!@mysql_connect($dbhost, $dbuser, $dbpw)) {
                    $this->show('Can not connect to MySQL server');
开启持续的连接池
                }        
                if($dbname) {
                        $this->select_db($dbname);
                }
                if($this->version() > '4.1') {
                    if($dbcharset) {                        
                         $this->query("SET NAMES '".$dbcharset."'");        
                    }
判断mysql的型号,对症下药
                }
        }

        function select_db($dbname) {
                return mysql_select_db($dbname);
把数据库名字返还
        }

        function fetch_array($query, $result_type = MYSQL_ASSOC) {
                return @mysql_fetch_array($query, $result_type);
要mysql_fetch_array里返回$query, $result_type
        }

下面不看了
某知名cms的结构
Jgwy.Com - Free Web Hosting Guide & Directory In China since 2001! Jgwy.Net-Jglt.Net
回复

使用道具 举报

 楼主| 发表于 2007 年 1 月 28 日 20:15:35 | 显示全部楼层
原帖由 破晓 于 2007-1-28 08:13 发表
class mysql{        
        function connect($dbhost, $dbuser, $dbpw, $dbname = '',$dbcharset='') {        
            if(!@mysql_connect($dbhost, $dbuser, $dbpw)) {
                    $thi ...


这个我就不知道了……

不过按照类的写法,感觉的确很爽
Jgwy.Com - Free Web Hosting Guide & Directory In China since 2001! Jgwy.Net-Jglt.Net
回复

使用道具 举报

y
发表于 2007 年 1 月 28 日 20:16:09 | 显示全部楼层
【腾讯云】2核2G云服务器新老同享 99元/年,续费同价
php4的类很WS...
Jgwy.Com - Free Web Hosting Guide & Directory In China since 2001! Jgwy.Net-Jglt.Net
回复

使用道具 举报

发表于 2007 年 1 月 28 日 20:49:45 | 显示全部楼层
还是asp好玩。。。
php玩长了无聊。。。
再说老婆也不学php,开始学asp了。。
Jgwy.Com - Free Web Hosting Guide & Directory In China since 2001! Jgwy.Net-Jglt.Net
回复

使用道具 举报

发表于 2007 年 1 月 28 日 21:02:52 | 显示全部楼层
   看地晕忽忽
Jgwy.Com - Free Web Hosting Guide & Directory In China since 2001! Jgwy.Net-Jglt.Net
回复

使用道具 举报

发表于 2007 年 1 月 28 日 21:11:35 | 显示全部楼层
楼上都素牛淫
路过一下
Jgwy.Com - Free Web Hosting Guide & Directory In China since 2001! Jgwy.Net-Jglt.Net
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|金光论坛

GMT+8, 2025 年 2 月 4 日 19:36 , Processed in 0.036111 second(s), 21 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表