phalcon executeQuery使用

在使用这个方法的时候常被返回结果所吓倒,以至于寻求其他方法
object(Phalcon\Mvc\Model\Query\Status)#76 (2) {
  ["_success":protected]=>
  bool(true)
  ["_model":protected]=>
  NULL
}
下面将举例说明这个方法执行更改数据

示例

<?php

$phql = "UPDATE Robots SET name = :name:, type = :type:, year = :year: WHERE id = :id:";

$status = $app->modelsManager->executeQuery(
    $phql,
    [
        "id"   => 100,
        "name" => "Astroy Boy",
        "type" => "mechanical",
        "year" => 1959,
    ]
);

// Check if the update was successful
if ($status->success() === true) {
    echo "OK";
}
返回结果的方法
Methods
public __construct (mixed $success, [Phalcon\Mvc\ModelInterface $model])

public getModel ()

Returns the model that executed the action

public getMessages ()

Returns the messages produced because of a failed operation

public success ()

Allows to check if the executed operation was successful

打印值

 public function test(){
//        $res = $this->modelsManager->executeQuery("delete from Front\Models\User_msg where user_id = " . $_SESSION['user_id'] . " and id in (" . $ids . ") ");
        $res = $this->modelsManager->executeQuery("delete from  Front\Models\Release_requir where  id =889");

        var_dump($res->getModel());
        var_dump($res->getMessages());
        var_dump($res->success());
        die();
        }
        
NULL
array(0) {
}
bool(true)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值