我想按ID更新帖子表。但是,当我尝试该教条更新帖子表中的所有行时,不仅仅是选择了id。
请注意,来自DriverManager的queryBuilder不是来自EntityManager
public function store(RequestInterface $request)
{
$db = new Config();
$db->queryBuilder()
->update("posts")
->set("title", "?")
->set("content", "?")
->where("id", "?")
->setParameter(0, $request->get("title"))
->setParameter(1, $request->get("content"))
->setParameter(2, $request->get("id"));
return redirect()->route("posts.index");
}
配置类
class Config
{
private $info;
public function __construct()
{
$this->info = [
'dbname' => 'cms',
'user' => 'root',
'password' => '123456',
'host' => 'localhost',
'driver' => 'pdo_mysql',
];
}
public function conn()
{
return DriverManager::getConnection($this->info, $this->config());
}
private function config()
{
return new Configuration();
}
public function queryBuilder()
{
return $this->conn()->createQueryBuilder();
}
上述代码有什么不对吗?如果是,我该如何解决?