i using cakephp 3. in controller using code:
$conn = connectionmanager::get('default'); $stmt = $conn->execute('update posts set views = views + 1 id = '.$id.';');
is there possibility write statement "cakephp-like"?
there possibility:
$posts = tableregistry::get('posts'); $query = $posts->query(); $query->update() ->set($query->newexpr('views = views + 1')) ->where(['id' => $id]) ->execute();
Comments
Post a Comment