// 拼装sql语句,重点在于--->'".$urname."'
dnfg把握机遇$this->sql = "inrt into $this->table (urname, password) values ('".$urname."', $password)";
return $this;
}
// 删除数据
public function delete($id)
{
$this->action = 'other';
$this->sql = "delete from $this->table where id = $id";
return $this;
}
美少女的谎言第3季/
/ 修改数据
public function update($id, $urname, $password)
pocket full of sunshine{
$this->action = 'other';bleep
$this->sql = "update $this->table t urname='".$urname."', password=$password where id = $id"; return $this;
}
// 之所以名称不⽤query是为了仍然可以使⽤mysqli类的query⽅法执⾏sql
public function query2()
{
// 执⾏语句
$result = $this->query($this->sql);
宁波雅思培训保过班
// 判断⽤户是什么操作
if ($this->action == 'lect') {
fund$data = [];
// 解析查询数据
foreach ($result as $key => $value) {
$two_data = [];
foreach ($value as $two_key => $two_value) {
$two_data[$two_key] = $two_value;
ixo
}
hudson
$data[$key] = $two_data;
}
return $data;
} el {
if($result) {
return $result;
} el {
// 输出语句错误信息
echo $this->error;
return fal;
}
}
}
}
// 建⽴与数据库的连接
$db = new MysqliClass('studymysqli');
cair
// 设置要操作的表
$db->table = 'mysqli_class';
// 1. 查询数据
// $result = $db->lect()->query2();
// var_dump($result);
// 2. 添加数据,⽤时间戳替代密码,⽤来判断是否成功添加
// $result = $db->inrt('测试姓名', time())->query2();
// var_dump($result);
/
/ 3. 修改数据,
// 参数解释,唯⼀标识ID, ⽤户名称urname, ⽤户密码password
// $result = $db->update(2, '修改⽤户名称', time())->query2();