CakePHP使用错误的序列名称(PostgreSQL) [英] CakePHP use wrong sequence name (PostgreSQL)

查看:78
本文介绍了CakePHP使用错误的序列名称(PostgreSQL)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试在Postgres表中保存一些信息时,CakePHP为我返回此错误:

When I try save some information in Postgres table, CakePHP return this error for me:

array(
    (int) 0 => '[PDOException] SQLSTATE[42P01]: Undefined table: 7 ERRO:  relação "public.cashier_transaction_transaction_num_seq" não existe
Request URL: /www/cashiers/open
Stack Trace:

但是CakePHP是正确的:该序列不存在。是 transaction_num_seq

But CakePHP is correctly: this sequence doesn't exist. The correct sequence is transaction_num_seq.

如何更改 IN CAKE (我无法更改数据库)。

How can I change that IN CAKE (I can't change the database).

推荐答案

例如,我发现解决此错误的唯一方法是在每个名为 nextval()的模型中创建一个动作,并运行默认的PostgreSQL查询以获取下一个序列。

The only way I found to fix this error, was creating an action in each model named "nextval ()" for example, and run the default PostgreSQL query to get the next sequence.

public function nextval() {
    $sql = "select nextval('transaction_num_seq') as nextval";
    $result = $this->query($sql);
    return $result[0][0]['nextval'];
}

这篇关于CakePHP使用错误的序列名称(PostgreSQL)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆