Reference to parent record

A place for users and developers of the Xataface to discuss and receive support.

Postby fbermudez » Mon Aug 21, 2006 8:01 am

I'm displaying a relationship with all records form a parent record.
I want to display totals of the records in the relationship, at the
block__after_related_records_list, which is correctly located since I can echo it OK.

However, what I need is to have the totals without having to query the database on literal parameters:

Get the related records in the relationship from the Current Record... That's why the example in the documentation doesn«t work for me.

My code is now:
require_once 'Dataface/RelatedRecord.php';
$record = Dataface_RelatedRecord::getParent();
$variable_array =& $record->getRelatedRecords('Relationship_name');

but I allways get an empty, non Dataface_Record result.
What's funny is that it works if I place it in
class tables_partidos {
function getTitle(&$record)
but that's not where I want it.

I can either access the current record or work with the array of the body of Related Record, but I can«t figure pout where it's stored, and I'm sure it's somewhere.

Can anyone help, Thanks FB
fbermudez
 
Posts: 14
Joined: Wed Dec 31, 1969 5:00 pm

Postby shannah » Mon Aug 21, 2006 9:13 am

I think that you probably want to do something like this:

Code: Select all
$app =& Dataface_Application::getInstance();
$record =& $app->getRecord();  // get the parent record
$variable_array =& $record->getRelatedRecords('Relationship_name');


The Dataface_RelatedRecord::getParent() method can't be called from a static context. This is one of the reasons why your current code won't work.

Hope this helps a little

-Steve
--
Steve Hannah
@shannah78 (on twitter)
sjhannah.com blog
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 99 guests

cron
Powered by Dataface
© 2005-2007 Steve Hannah All rights reserved