DataObject, DataGrid and joins

From: Date: Wed, 16 Nov 2005 13:52:57 +0000
Subject: DataObject, DataGrid and joins
Groups: php.pear.general 
Request: Send a blank email to pear-general+get-21942@lists.php.net to get a copy of this message
Hello Please help. I've tried all sorts of combinations and the results just get weirder. Firstly, if I create the DG with only one DO, it produces the correct output. As soon as I attempt to join another table, the only things output are the column headings. Please advise if I've used the wrong syntax to call the fields Next, with "$dg->renderer->setFilename(datagrid.xls');" two Excel spreadsheets are created. If I use "$dg->renderer->setFilename(datagrid.xls',false);" as recommended in the Changelog for 0.6.3 then no spreadsheets are created. Both behaviours are repeatable. At one point, when using "$dg->renderer->setFilename(datagrid.xls');" two DIFFERENT spreadsheets were created. One was as per the defined columns and another with the same columns PLUS the name of one of the 'joined' tables and an extra linked id field from the DO that called the join?????? This also was repeatable until I rebooted the PC. Please advise how to fix. The SDG version is 0.6.3 and my code is: <snip> $obj1= new DataObjects_Obj1(); $obj2= new DataObjects_Obj2(); $obj3= new DataObjects_Obj3(); // As recommended by Olivier Guilyardi (2005-11-08) $obj2->selectAs(); $obj2->joinAdd($obj3); $obj2->selectAs($obj3, 'obj3_%s'); $obj1->selectAs(); $obj1->joinAdd($obj2); $obj1->selectAs($obj2, obj2_%s'); $obj1->groupBy('name'); $obj1->orderBy('name'); // Create a new SDG object $dg =& new Structures_DataGrid(null, null, DATAGRID_RENDER_XLS); // Fields from Obj1 $dg->addColumn(new Structures_DataGrid_Column('Name', 'name', 'name', array('width' => '50'))); $dg->addColumn(new Structures_DataGrid_Column(Number, number, number, array('width' => '10'))); // Field from Obj3 $dg->addColumn(new Structures_DataGrid_Column(obj3name, obj2_obj3_obj3name, obj2_obj3_obj3name, array('width' => '11'))); // Fields from Obj2 $dg->addColumn(new Structures_DataGrid_Column('Junior', obj2_junior', obj2_junior', array('width' => '3'))); $dg->addColumn(new Structures_DataGrid_Column('Gradingpts', obj2_gradingpts', obj2_gradingpts', array('width' => '4'))); $dg->bind($obj1); // Set the initial sort order $dg->sortRecordSet($orderBy, $dir); // Get a reference to the Renderer object $renderer =& $dg->getRenderer(); // Get a reference to the HTML Renderer object $dg->renderer->setFilename(datagrid.xls',false); $dg->render(); return; </snip>

« previous php.pear.general (#21942) next »