Page 1 of 1

Error on remove related record

PostPosted: Thu Mar 13, 2008 2:56 pm
by fantomasdm
Hi, when I try to remove relative record I get this error:
Fatal error: Call to undefined method PEAR_Error::getTitle() in /var/www/vhosts/lotta.genesisliceo.it/httpdocs/dataface-0.7.1/Dataface/RemoveRelatedRecordForm.php on line 211

table that I use is:
anagrafica with idanagrafica as primary key
palestra with idpalestra as primary key
corsi with (idpalestra,idanagrafica) as primary key

file relationship.ini on tables/anagrafica
[Corsi]
palestra.idpalestra = corsi.idpalestra
corsi.idanagrafica = "$idanagrafica"

file relationship.ini on tables/palestra
[Allievi]
anagrafica.idanagrafica = corsi.idanagrafica
corsi.idpalestra = "$idpalestra"

When I use RelationShip Corsi on Palestra all works well (add new, add exist, remove) but on RelationShip Corsi on Anagrafica add new and add exist works but remove give me an error.
Thank for help....ans sorry for my English!!!

PostPosted: Fri Mar 14, 2008 12:55 pm
by shannah
Try the fix suggested at the end of this thread:
http://xataface.com/forum/viewtopic.php?t=4137#20782

PostPosted: Fri Mar 14, 2008 5:20 pm
by fantomasdm
I have try the fix, but I get the same error!!

PostPosted: Fri Mar 14, 2008 6:16 pm
by shannah
Not sure why it's happening then. You could do a little debugging:

First. On the related record llist just before you click "Remove", view the HTML source. Each row has a checkbox beside it. I'm interested in the HTML markup for these checkboxes. It will look something like:

Code: Select all



I'm curious what the id parameters say.

Second, you can modify the RemoveRelatedRecordForm.php file to add some debugging:

Just before line 211 add:
Code: Select all
if ( PEAR::isError($record) ) echo $record->getMessage();


This should print out an error message just before the fatal error that might give us a bit more of a clue.

PostPosted: Sat Mar 15, 2008 5:41 am
by fantomasdm
Hi, first of all, thank for help!
The html code in relative record list is:
for first record:
Code: Select all
input class="rowSelectorCheckbox" id="rowSelectorCheckbox:anagrafica/Corsi?idanagrafica=18&Corsi%3A%3Aidpalestra=2&Corsi%3A%3Aidanagrafica=18" type="checkbox"

for second record:
Code: Select all
input class="rowSelectorCheckbox" id="rowSelectorCheckbox:anagrafica/Corsi?idanagrafica=18&Corsi%3A%3Aidpalestra=3&Corsi%3A%3Aidanagrafica=18" type="checkbox"


the debug output is:
Could not find any related records matching the query: `idpalestra`='3' and `idanagrafica`='18'


the values In table Corsi is:
Idpalestra Idanagrafica
3 12

2 18

3 18
in table Corsi fields idpalestra and idanagrafica is integer type.

PostPosted: Sat Mar 15, 2008 10:36 am
by shannah
This is very strange. Clearly the record that it says it can't find exists.

One thing that may or may not be related:
I see you capitalizing column names in some cases (e.g. Idpalestra Idanagrafica) and in other cases using all small letters. Xataface is case sensitive. Hence column names and table names should use consistent case-sensitivity.

e.g.
if the table name is idanagrafica, always use 'idanagrafica' and not 'Idanagrafica'. Similarly if the column is 'Idpalestra' always use 'Idpalestra' and not 'idpalestra'.

Again.. I don't know if this is the cause of the problem, but it is something to look at.

If that doesn't do it, I may need to take a look at the source myself. If you can either give me temporary FTP access to the source to try myself, or send me the source code so that I can try it out on my own server.

My email address is steve@weblite.ca

Best regards

Steve

PostPosted: Tue Mar 18, 2008 1:39 pm
by fantomasdm
HI! I have rename fields of table corsi from idanagrafica to anagrafica and idpalestra to palestra now the relationships.ini is
for table palestra
[Allievi]
corsi.anagrafica = anagrafica.idanagrafica
corsi.palestra = "$idpalestra"
for table anagrafica
and
[Corsi]
corsi.palestra = palestra.idpalestra
corsi.anagrafica = "$idanagrafica"

and now works all!!
I think that the problem is that the name of filed idanagrafica is the same in table corsi and in table anagrafica for relation in anagrafica, same situation in relation palestra where the same field is idpalestra!!

thanks for Help!
......and sorry for my bad english

PostPosted: Wed Mar 19, 2008 10:12 am
by shannah
Glad to hear it is working. I looked at your table structure and found the problem. The palestra table has a column named idanagrafica. This column confuses Xataface because when it performs the relationship query the palestra.idanagrafica column was overriding the value of the corsi.idanagrafica field.

Hence why changing the name got it working.

As an example, Xataface tries to perform the query:
Code: Select all
select `corsi`.`idpalestra`, `corsi`.`idanagrafica`, `palestra`.`idpalestra`, `palestra`.`club`, `palestra`.`idanagrafica`, `palestra`.`indirizzo`, `palestra`.`orario`, `palestra`.`telefono`, length(`corsi`.`idpalestra`) as `__idpalestra_length`, length(`corsi`.`idanagrafica`) as `__idanagrafica_length`, length(`palestra`.`idpalestra`) as `__idpalestra_length`, length(`palestra`.`club`) as `__club_length`, length(`palestra`.`idanagrafica`) as `__idanagrafica_length`, length(`palestra`.`indirizzo`) as `__indirizzo_length`, length(`palestra`.`orario`) as `__orario_length`, length(`palestra`.`telefono`) as `__telefono_length` from `corsi`, `palestra` where `corsi`.`idpalestra` = `palestra`.`idpalestra` and `corsi`.`idanagrafica` = '24' LIMIT 0,30


If you run this you notice that it has two columns named idanagrafica. The first has the correct value '24' but the second has a value of '0'.

-Steve