简体   繁体   English

我的插入语句有什么问题?

[英]What is wrong with my Insert statement?

For some reason, I can only select data from a table but I can't insert. 由于某些原因,我只能从表中选择数据,但不能插入。

Ie function nee() works fine, but wee() doesn't... It was working earlier today... anyone know the reason? 即函数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();

这样尝试

$st = $this->db->prepare("insert into sales(paid) values ('sdf')");

whats sdf? 什么是sdf? is it a text/string, then use ' around it 它是文本/字符串,然后在其周围使用“

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM