我的Insert语句有什么问题?

时间:2012-06-30 17:56:11

标签: php mysql

出于某种原因,我只能从表格中选择数据,但我无法插入。

即。函数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();

2 个答案:

答案 0 :(得分:2)

试试这个

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

答案 1 :(得分:1)

什么是sdf?是文本/字符串,然后使用'around it