Code前端首页关于Code前端联系我们

关于db.class.php的信息

terry 2年前 (2023-09-30) 阅读数 53 #PHP
文章标签 PHP dirname()

本文目录一览:

  • 1、错误位置: FILE:/www/shidu/ThinkPHP/Lib/Core/Db.class.php LINE:640 在线等 急啊。
  • 2、php.Db.class.写法
  • 3、错误位置: FILE: D:\wwwroot\navicle\t\Lib\Core\Db.class.php LINE: 214如何解决的
  • 4、新手求助,有Db.class.php,Class Db'not found

错误位置: FILE:/www/shidu/ThinkPHP/Lib/Core/Db.class.php LINE:640 在线等 急啊。

这种的肯定不是这个db.class.php的错误

看看调试模式是否开启了,没有开启的建议开启就能看到详细的报错信息了

或者贴出你的代码

php.Db.class.写法

?php

class Db{

public $host;

public $username;

public $password;

public $database;

public $conn;

public $table;

public $sql;

public $field = '*';

function __construct($host,$username,$password,$database){

$this-host = $host;

$this-username = $username;

$this-password = $password;

$this-database = $database;

$this-connect();

}

function connect(){

$this-conn = new mysqli($this-host, $this-username, $this-password,$this-database);

if ($this-conn-connect_error) {

die("连接失败: " . $this-conn-connect_error);

}

}

function M($table){

$this-table = $table;

return $this;

}

function where($array){

$this-sql = '';

$sql = 'where ';

$one = '';

if($array){

if(is_array($array)){

foreach($array as $key=$vo){

$one .= '`'.$key.'` = "'.$vo.'" and';

}

$one = trim($one,'and');

$sql .= $one;

$this-sql = $sql;

}else{

$sql .= $array;

$this-sql = $sql;

}

}

return $this;

}

function add($array){

$sql = 'insert into `'.$this-table.'` (';

$one = '';

$two = '';

if($array){

if(is_array($array)){

foreach($array as $key=$vo){

$one .= '`'.$key.'` ,';

$two .= '"'.$vo.'",';

}

$one = trim($one,',');

$two = trim($two,',');

if($one $two){

$sql .= $one.') values ('.$two.')';

$this-sql = $sql;

$r = $this-conn-query($this-sql);

if($r){

return mysqli_insert_id($this-conn);

}else{

return false;

}

}

}else{

exit('非数组');

}

}else{

exit('数组为空');

}

}

function select(){

$array = '';

$sql = 'select '.$this-field.' from `'.$this-table.'`'.$this-sql;

$result = $this-conn-query($sql);

if ($result-num_rows 0) {

while($row = $result-fetch_assoc()) {

$array[] = $row;

}

}

return $array;

}

function find(){

$row = '';

$sql = 'select '.$this-field.' from `'.$this-table.'`'.$this-sql.'limit 1';

$result = $this-conn-query($sql);

$row = $result-fetch_assoc();

return $row;

}

function edit($array){

$sql = 'update `'.$this-table.'` set ';

$one = '';

if($array){

if(is_array($array)){

foreach($array as $key=$vo){

$one .= '`'.$key.'` = "'.$vo.'",';

}

$one = trim($one,',');

$sql .= $one.' '.$this-sql;

}else{

$sql .= $array.' '.$this-sql;

}

$r = $this-conn-query($sql);

if($r){

return true;

}else{

return false;

}

}else{

exit('未接收到参数');

}

}

function delete(){

$sql = 'delete from `'.$this-table.'` ';

$sql .= $this-sql;

$r = $this-conn-query($sql);

if($r){

return true;

}else{

return false;

}

}

function order($data){

$this-sql = $this-sql.' order by '.$data;

return $this;

}

function limit($data){

$this-sql = $this-sql.' limit '.$data;

return $this;

}

function field($data){

$this-field = $data;

return $this;

}

}

$db = new Db('localhost','root','root','database');

?

错误位置: FILE: D:\wwwroot\navicle\t\Lib\Core\Db.class.php LINE: 214如何解决的

1:用户名密码不对

2:权限设置的有问题,你可以在 phpmyadmin里,找到用户列表,然后设置权限。

版权声明

本文仅代表作者观点,不代表Code前端网立场。
本文系作者Code前端网发表,如需转载,请注明页面地址。

热门