Php 我的Insert语句有什么问题?
由于某些原因,我只能从表中选择数据,但无法插入 也就是说,函数Php 我的Insert语句有什么问题?,php,mysql,Php,Mysql,由于某些原因,我只能从表中选择数据,但无法插入 也就是说,函数nee()可以正常工作,但wee()不能。。。今天早些时候它还在工作。。。有人知道原因吗 Class wtf{ private $db; public function __construct(){ $this->db = new Store_Connection(); $this->db = $this->db->dbStore(); } pu
nee()
可以正常工作,但wee()
不能。。。今天早些时候它还在工作。。。有人知道原因吗
Class wtf{
private $db;
public function __construct(){
$this->db = new Store_Connection();
$this->db = $this->db->dbStore();
}
public function nee(){
$st = $this->db->prepare("select paid from sales where id=14");
$st->execute();
$product = $st->fetch(PDO::FETCH_OBJ);
print_r($product);
}
public function wee(){
$st = $this->db->prepare("insert into sales(paid) values (sdf)");
$st->execute();
}
}
$work = new wtf();
$work->wee();
什么是自卫队?它是一个文本/字符串,然后在它周围使用'sdf'?如果是文本/字符串,请在其周围使用'
$st = $this->db->prepare("insert into sales(paid) values ('sdf')");
像这样试试
$st = $this->db->prepare("insert into sales(paid) values ('sdf')");
为什么要使用没有参数的准备语句?什么意思?还有
$this->db=newstore_Connection()代码>闻起来像是坏代码。你为什么要这样做$this->db=$this->db->dbStore()代码>我写这个只是为了检查它是否有效,所以我没有使用参数。我跟踪了一段youtube视频,他们这样做了$this->db。为什么要使用没有参数的预处理语句?什么意思?还有$this->db=newstore_Connection()代码>闻起来像是坏代码。你为什么要这样做$this->db=$this->db->dbStore()代码>我写这个只是为了检查它是否有效,所以我没有使用参数。我跟踪了一段youtube视频,他们这样做了$this->db。