| View previous topic :: View next topic |
| Author |
Message |
shaggydog97
Joined: 18 Jul 2007 Posts: 10
|
Posted: Thu Jul 19, 2007 10:53 pm Post subject: DataGrid and DataSource links.ini question |
|
|
DataGrid doesn't seem to be following my links.ini file by default. If I use FormBuilder on the dataObject, it works fine. If I call getLinks(), I can see this in a print_r of my datagrid object, and the datagrid only displays the link id's...
Idea's?
[code]
[_lastError] => DB_DataObject_Error Object
(
[error_message_prefix] =>
[mode] => 1
[level] => 1024
[code] => -2
[message] => DB_DataObject Error: getLink: row not set rowname
[userinfo] =>
[backtrace] => Array
(
[0] => Array
(
[file] => /usr/share/pear/DB/DataObject/Error.php
[line] => 44
[function] => PEAR_Error
[class] => PEAR_Error
[object] => DB_DataObject_Error Object
*RECURSION*
[type] => ->
[args] => Array
(
[0] => DB_DataObject Error: getLink: row not set rowname
[1] => -2
[2] => 1
[3] => 1024
)
)
[/code] |
|
| Back to top |
|
 |
mark

Joined: 07 Jan 2007 Posts: 1000
|
Posted: Fri Jul 20, 2007 12:05 pm Post subject: |
|
|
| I'm not familiar with DBDO, but this seems to be more an issue with DBDO than with SDG. Are you sure that you have configured DBDO right in your script? |
|
| Back to top |
|
 |
shaggydog97
Joined: 18 Jul 2007 Posts: 10
|
Posted: Fri Jul 20, 2007 5:33 pm Post subject: |
|
|
A call to $dbdo->getLinks will not work unless you select a specific record with $dbdo->get() or a $dbdo->find() / $dbdo->fetch(). But if you do this first to the dbdo then the SDG will not load the grid.
I have tried using this code:
| Code: |
$options = array('link_level' => 2, 'link_keep_key' => true);
$driver =& Structures_DataGrid::dataSourceFactory(DB_DataObject::factory('table'), $options, DATAGRID_SOURCE_DATAOBJECT);
$datagrid =& new Structures_DataGrid(20, null, DATAGRID_RENDER_SMARTY);
$datagrid->bindDataSource($driver);
|
But it seems that the dataSourceFactory() method options may not be working correctly.
Not sure what options I really need to get this going |
|
| Back to top |
|
 |
shaggydog97
Joined: 18 Jul 2007 Posts: 10
|
Posted: Fri Jul 20, 2007 9:08 pm Post subject: Arrrgghh |
|
|
| Updated /Structures/DataGrid/DataSource.php from CVS, and it fixed it... I now have a new set of issues, like figuring out how to get my datatabe to show only one field from the linked table... |
|
| Back to top |
|
 |
mark

Joined: 07 Jan 2007 Posts: 1000
|
Posted: Fri Jul 20, 2007 10:07 pm Post subject: |
|
|
| shaggydog97 wrote: | I have tried using this code:
| Code: |
$options = array('link_level' => 2, 'link_keep_key' => true);
$driver =& Structures_DataGrid::dataSourceFactory(DB_DataObject::factory('table'), $options, DATAGRID_SOURCE_DATAOBJECT);
$datagrid =& new Structures_DataGrid(20, null, DATAGRID_RENDER_SMARTY);
$datagrid->bindDataSource($driver);
|
|
Just a comment on this code: Why do you use dataSourceFactory() here? Using just bind() with your DBDO instance would save one line of code. And DBDO should also be auto-detected, so there should be no need for the third parameter. |
|
| Back to top |
|
 |
shaggydog97
Joined: 18 Jul 2007 Posts: 10
|
Posted: Mon Jul 23, 2007 2:54 pm Post subject: |
|
|
I was trying it both ways, and eventually, changed it back to just bind.
When datagrid follows a link, it is using the getLink() method. The problem is it generates a select * sub query, which returns the whole row as a 'csv' string. I am curious as to where I can specify a column from this sub query to be returned.
It seems as though I might have to define a 'fields' property, but from looking at the source for Structures/DataGrid/DataSource.php, I don't see how this could work.
If I have to specify this somewhere, I would think it should be in the links.ini file or in the DataObject class. If I had to pass an array it would defeat the MVC pattern, that is in place here.
What might just end up happening, is overriding the getLink() method for each DataObject, but this might break FormBuilder on the same Objects.
Any thoughts? |
|
| Back to top |
|
 |
mark

Joined: 07 Jan 2007 Posts: 1000
|
Posted: Mon Jul 23, 2007 3:13 pm Post subject: |
|
|
| You should get more help on the DBDO driver issues on the pear-general mailing list. Both the author of DBDO and the author of the SDG DBDO driver are reading the list. |
|
| Back to top |
|
 |
shaggydog97
Joined: 18 Jul 2007 Posts: 10
|
Posted: Mon Jul 23, 2007 4:11 pm Post subject: |
|
|
| thanks |
|
| Back to top |
|
 |
|