php的phalcon框架的db怎样获取mysql执行过程中的错误信息?


phalcon中的数据库操作类Phalcon\Db,Phalcon\Db\Adapter\Pdo, Phalcon\Db\Adapter\Pdo\Mysql。这几个我看了,都没有数据库执行出错后获取相应错误的方法,不知道是怎么回事,有没有知道的啊?

php phalcon

ashero 10 years, 7 months ago

如果是working with models则

$robot       = new Robots();
$robot->type = "mechanical";
$robot->name = "Astro Boy";
$robot->year = 1952;
if ($robot->save() == false) {
    echo "Umh, We can't store robots right now: \n";
    foreach ($robot->getMessages() as $message) {
        echo $message, "\n";
    }
} else {
    echo "Great, a new robot was saved successfully!";
}

如果是phql则

$phql   = "INSERT INTO Cars VALUES (NULL, 'Nissan Versa', 7, 9999.00, 2012, 'Sedan')";
$result = $manager->executeQuery($phql);
if ($result->success() == false)
{
    foreach ($result->getMessages() as $message)
    {
        echo $message->getMessage();
    }
}
爱吃肉的米子酱 answered 10 years, 7 months ago

Your Answer