But thanks anyway.
On 25 nov, 13:35, teknoid <teknoid.cake...@gmail.com> wrote:
> I assume in that case you'll need to create a model for your join
> table (which is otherwise created for you)...
> and specify which schema (db) it uses.
> Otherwise, if you can, move them all to the same schema.
>
> On Nov 25, 7:55 am, Antônio Marco <idelfonso.alme...@gmail.com> wrote:
>
> > Thanks, teknoid!
>
> > But now I'm having a new problem... My applications uses tables
> > separated indifferentschemas. These tables are related one each
> > other as shown above.
>
> > I'm trying the HBTM association between "geo.plots" and
> > "dme.addresses" tables. I created the "geo.addresses_plots" table but
> > when I run my application I receives the message bellow:
>
> > Warning (2): pg_query() [function.pg-query]: Query failed: ERRO:
> > relation "addresses_plots" do not exists [CORE.rc2/libs/model/
> > datasources/dbo/dbo_postgres.php, line 152]
>
> > Can you help me once more?
>
> > I hope so.
>
> > On 24 nov, 18:50, teknoid <teknoid.cake...@gmail.com> wrote:
>
> > > This is a basic HABTM (hasAndBelongsToMany) relationship.
> > > Read up on it in the manual... you should also rename the join table
> > > (if you'd like to keep consistent with conventions).
>
> > > On Nov 24, 2:40 pm, Antônio Marco <idelfonso.alme...@gmail.com> wrote:
>
> > > > Hi folks!
>
> > > > I created 3 tables as shown bellow:
>
> > > > CREATE TABLE geo.plots
> > > > (
> > > > id serial NOT NULL,
> > > > created timestamp,
> > > > modified timestamp,
>
> > > > the_geom varchar(255),
>
> > > > inscricao_imobiliaria varchar(14) NOT NULL,
>
> > > > quadra varchar(10),
> > > > lote smallint,
>
> > > > numero_residencial_previo smallint,
>
> > > > PRIMARY KEY (id)
> > > > )
> > > > WITH OIDS;
>
> > > > CREATE TABLE geo.plot_addresses
> > > > (
> > > > id serial NOT NULL,
> > > > created timestamp,
> > > > modified timestamp,
>
> > > > plot_id int NOT NULL,
> > > > address_id int NOT NULL,
>
> > > > endereco_principal bool NOT NULL DEFAULT true,
>
> > > > PRIMARY KEY (id),
> > > > FOREIGN KEY (plot_id) REFERENCES geo.plots (id),
> > > > FOREIGN KEY (address_id) REFERENCES dme.addresses (id)
> > > > )
> > > > WITH OIDS;
>
> > > > CREATE TABLE dme.addresses
> > > > (
> > > > id serial NOT NULL,
> > > > created timestamp,
> > > > modified timestamp,
>
> > > > habilitado bool NOT NULL DEFAULT true,
>
> > > > street_postal_code_id int NOT NULL,
> > > > parent_id int,
>
> > > > complemento bool NOT NULL DEFAULT false,
>
> > > > numero smallint,
>
> > > > bloco varchar(10),
> > > > andar smallint,
> > > > unidade smallint,
>
> > > > posicao smallint,
>
> > > > caixa_postal smallint,
>
> > > > complemento_livre varchar(255),
>
> > > > PRIMARY KEY (id),
>
> > > > FOREIGN KEY (street_postal_code_id) REFERENCES
> > > > dme.street_postal_codes (id),
> > > > FOREIGN KEY (parent_id) REFERENCES dme.addresses (id)
> > > > )
> > > > WITH OIDS;
>
> > > > They are associated as shown bellow:
>
> > > > //
> > > > class Plot extends AppModel {
> > > > var $name = 'Plot';
>
> > > > var $useDbConfig = 'geo';
>
> > > > var $hasMany = array(
> > > > 'PlotAddresses' => array(
> > > > 'className' => 'PlotAddress',
> > > > 'foreignKey' => 'plot_id'
> > > > )
> > > > );
>
> > > > }
>
> > > > //
> > > > class PlotAddress extends AppModel {
> > > > var $name = 'PlotAddress';
>
> > > > var $useDbConfig = 'geo';
>
> > > > var $belongsTo = array(
> > > > 'Plot' => array(
> > > > 'className' => 'Plot',
> > > > 'foreignKey' => 'plot_id'
> > > > ),
>
> > > > 'Address' => array(
> > > > 'className' => 'Address',
> > > > 'foreignKey' => 'address_id'
> > > > )
> > > > );
>
> > > > }
>
> > > > //
> > > > class Address extends AppModel {
> > > > var $name = 'Address';
>
> > > > var $useDbConfig = 'dme';
>
> > > > var $hasOne = array(
> > > > 'PlotAddress' => array(
> > > > 'className' => 'PlotAddress',
> > > > 'foreignKey' => 'address_id'
> > > > )
> > > > );
>
> > > > }
>
> > > > I have used Scaffolding in this application but when I run the index
> > > > of PlotAddresses, I receive the message bellow:
>
> > > > Notice (8): Undefined index: Address [CORE.rc2/libs/view/scaffolds/
> > > > index.ctp, line 81]
>
> > > > Verifing the line, I saw that the problem is related to "belongTo"
> > > > association.
>
> > > > Can anybody help me to solve this problem? Is my association
> > > > incorrect?
>
> > > > Thanks a lot.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---
No comments:
Post a Comment