备份还原的问题

#1 kao10324

     function __construct(){ // 公用
        parent::__construct(); // 这是必须的
        $this->connect();
    }

    function connect(){
        header('Content-type: text/html;charset=utf-8');
        require(APP_PATH."/config.php");
        $host=$spConfig["db"]['host'];
        $log=$spConfig["db"]['login'];
        $pass=$spConfig["db"]['password'];
        $db=$spConfig["db"]['database'];
        $con=mysql_connect($host,$log,$pass)or die(mysql_error());
        mysql_query("set names utf8");
        mysql_select_db($db)or die(mysql_error());
    }
为什么我写备份/还原函数.一定要进行上面这个数据库连接..写其它的操作.也进行了数据库的读写..而不需要上面这个连接就可以

2012-08-16 11:12:25

#2 Pony

备份?还原?详细一点吧,用spModel就可以了,不需要这样手动写连接代码

2012-08-16 11:17:52

#3 kao10324

Pony 发表于 2012-8-16 11:17
备份?还原?详细一点吧,用spModel就可以了,不需要这样手动写连接代码
function manage(){
                $resource_tables = mysql_query("show tables");
                while($rows = mysql_fetch_row($resource_tables)){
                        $sql = "select * from $rows[0]";
                        $count = mysql_num_rows(mysql_query($sql));        //取得结果集的记录数
                        $rows['tablename'] = $rows[0];
                        $rows['count'] = $count;
                        $tables[] = $rows;
                }
                $this->tables = $tables;
                $this->display("admin/data/manage.html");
        }

执行这个.没写那个连接的话.这些语句都无效

2012-08-16 14:35:33

#4 Pony

你用findSql()就可以了

2012-08-16 14:41:45

#5 kao10324

嗯.谢了

2012-08-16 15:16:35