Skip to content

Commit 232f219

Browse files
author
方智杰
committed
修改数据连接类为mysqli,删除.htaccess文件
1 parent 474a3ae commit 232f219

File tree

6 files changed

+50
-460
lines changed

6 files changed

+50
-460
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/.idea
2+
/vender
3+
/composer.lock
4+
/Application/log/error_log

.htaccess

Lines changed: 0 additions & 1 deletion
This file was deleted.

Application/Config/config.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
'database'=>array(
1212
'host' => '127.0.0.1',
1313
'user' => 'root',
14-
'pwd' => '',
14+
'pwd' => 'root',
1515
'dbname'=> 'product'
1616
),
1717
//应用程序的配置信息

Application/log/error_log

Lines changed: 39 additions & 452 deletions
Large diffs are not rendered by default.

Framework/Core/Model.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ private function getTable(){
2121
//获得主键字段
2222
private function getPrimaryKey($table){
2323
$rs=$this->db->query("desc `{$table}`");
24-
while ($rows=mysql_fetch_assoc($rs)) {
24+
while ($rows=mysqli_fetch_assoc($rs)) {
2525
# code...
2626
if ($rows['Key']=='PRI') {
2727
# code...

Framework/Core/MySQLDB.class.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ private function initParam($config) {
2020
}
2121
//连接数据库
2222
private function connect() {
23-
$this->link=@mysql_connect("{$this->host}:{$this->port}",$this->user,$this->pwd) or die('数据库连接失败');
23+
$this->link=mysqli_connect("{$this->host}:{$this->port}",$this->user,$this->pwd,$this->dbname) or die('数据库连接失败');
2424
}
2525
//设置字符编码
2626
private function setCharset() {
@@ -47,12 +47,12 @@ function mLog($log){
4747
*如果是数据操作语句,成功返回true,失败返回false;
4848
*/
4949
public function query($sql) {
50-
if(!$result=mysql_query($sql,$this->link)){
50+
if(!$result=mysqli_query($this->link,$sql)){
5151
//mLog($sql."\n".mysql_error());
5252
if($GLOBALS['config']['app']['app_debug']){//开发模式
5353
echo 'SQL语句执行失败<br>';
54-
echo '错误编号:'.mysql_errno(),'<br>';
55-
echo '错误信息:'.mysql_error(),'<br>';
54+
echo '错误编号:'.mysqli_errno(),'<br>';
55+
echo '错误信息:'.mysqli_error(),'<br>';
5656
echo '错误的SQL语句',$sql,'<br>';
5757
exit;
5858
}
@@ -97,7 +97,7 @@ public function fetchAll($sql,$fetch_type='assoc') {
9797
$fetch_types=array('assoc','row','array');
9898
if(!in_array($fetch_type,$fetch_types))
9999
$fetch_type='assoc';
100-
$fetch_fun='mysql_fetch_'.$fetch_type;
100+
$fetch_fun='mysqli_fetch_'.$fetch_type;
101101
$array=array();
102102
while($rows=$fetch_fun($rs)){
103103
$array[]=$rows;

0 commit comments

Comments
 (0)