php - 奇怪的 mysql_update 函数似乎只获取 $this-> info

标签 php mysql

好吧,由于某种原因,我只收到发送到 mysql 数据库的 $this-> 信息

即:应该是这个

"UPDATE `shop_products` SET shopid = 1 WHERE id = 42"

但是我得到了这个

"UPDATE `shop_products` SET 1 WHERE 42"

这是我正在使用的代码。 我不知道为什么这不起作用

public function addstoreproduct($id,$shopid,$categoryid,$productname,$description,$price,$rcb)
    {
        $this->id = $id;
        $this->shopid = $shopid;
        $this->categoryid = $categoryid;
        $this->productname = $productname;
        $this->descriptionid = $description;
        $this->price = $price;
        $this->rcb = $rcb;

        mysql_query("UPDATE `shop_products` SET shopid = "+$this->shopid+" WHERE id = "+$this->id+"");

        //$this->updatedb('shop_products','shopid='+$this->shopid+'','"id='+$this->id+'"');


    }

最佳答案

尝试

mysql_query("UPDATE shop_products SET shopid = ". $this->shopid . "WHERE id = ". $this->id);

关于php - 奇怪的 mysql_update 函数似乎只获取 $this-> info,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7923896/

相关文章:

php - 如何通过 apache 呈现 .phtml 文件

php - 禁用自动电子邮件日志

php - 我无法将 Mysql 查询转换为 laravel 查询生成器

mysql - 使用默认值创建表会出现错误

mysql - Devart LinqConnect for mysql 字段初始值设定项无法引用非静态字段、方法或属性

php - 字母表中的每个字母是否至少在一个字符串中出现一次?

php - 变量值没有传递到函数中?

php - CakePHP3 : How to run custom SQL query in table model

mysql - SQL join, sum, group-by 而不是 null 0

mysql - 查询缓存和缓冲池无法提供帮助,在磁盘上创建了很多表