Php 如果外键表列不存在';t与oracle中引用的父表列不匹配+;yii框架?

Php 如果外键表列不存在';t与oracle中引用的父表列不匹配+;yii框架?,php,oracle,yii,Php,Oracle,Yii,我有两张桌子,A桌和B桌 现在表A有A.id和B有B.id,其中B.id是链接A.id 现在我的问题是,A有一个.extraid,它在B中“有”多行,其中列名是B.notsamextraid。换句话说,B.notsamextraid的值与A.extraid 我应该怎么做才能让Yii匹配这两列,它们都有不同的名称 (我无权将B.notsamextraid的名称更改为B.extraid)Yii文档中说 你能试试下面的表格吗?Yii应该能够拾取两个外键: create table a ( id

我有两张桌子,A桌和B桌

现在表A有
A.id
和B有
B.id
,其中
B.id
是链接
A.id

现在我的问题是,A有一个.extraid,它在B中“有”多行,其中列名是
B.notsamextraid
。换句话说,
B.notsamextraid
的值与
A.extraid

我应该怎么做才能让Yii匹配这两列,它们都有不同的名称


(我无权将B.notsamextraid的名称更改为B.extraid)

Yii文档中说

你能试试下面的表格吗?Yii应该能够拾取两个外键:

create table a (
  id      int not null primary key,
  extraid int not null unique
);

create table b (
  id            references a(id),
  notsamextraid references a(extraid)
);
编辑:要确定两个表之间是否已经存在外键,可以使用以下查询。这不是地球上最漂亮的查询,但还有复制和粘贴:-)


我无权更改表…顺便说一句,我在使用oracle…在Yii框架中没有解决这个问题的方法吗?你能问设置表的人表b和a之间是否有两个外键约束吗?我明天可以问,但是,我是否可以使用任何oracle命令在sql developer中运行,以了解是否有两个关键限制?您可以访问sql developer,这太棒了。我已将查询放入答案中,因为我不知道如何将其放入注释中。如果
B.notsamextraid
a.extraid
之间没有外键,则可以尝试所述的Yii解决方法。
select t1.owner, t1.constraint_name, t1.constraint_type, t1.table_name, c1.column_name,
       t2.owner, t2.constraint_name, t2.constraint_type, t2.table_name, c2.column_name
  from all_constraints  t1
  join all_cons_columns c1
    on t1.constraint_name=c1.constraint_name
   and t1.owner=c1.owner 
   and t1.table_name=c1.table_name
  join all_constraints  t2
    on t1.owner=t2.owner
   and t1.r_constraint_name=t2.constraint_name
  join all_cons_columns c2
    on t2.constraint_name=c2.constraint_name
   and t2.owner=c2.owner 
   and t2.table_name=c2.table_name
   and c1.position=c2.position
 where t1.constraint_type = 'R'
   and t1.table_name in ('A','B');