PEAR Forum :: PHP Extension and Application Repository

PEAR Forum Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
DataGrid and DataSource links.ini question

 
Post new topic   Reply to topic    PEAR Forum Forum Index -> Structures
View previous topic :: View next topic  
Author Message
shaggydog97



Joined: 18 Jul 2007
Posts: 10

PostPosted: Thu Jul 19, 2007 10:53 pm    Post subject: DataGrid and DataSource links.ini question Reply with quote

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
View user's profile Send private message
mark



Joined: 07 Jan 2007
Posts: 1000

PostPosted: Fri Jul 20, 2007 12:05 pm    Post subject: Reply with quote

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
View user's profile Send private message
shaggydog97



Joined: 18 Jul 2007
Posts: 10

PostPosted: Fri Jul 20, 2007 5:33 pm    Post subject: Reply with quote

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
View user's profile Send private message
shaggydog97



Joined: 18 Jul 2007
Posts: 10

PostPosted: Fri Jul 20, 2007 9:08 pm    Post subject: Arrrgghh Reply with quote

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
View user's profile Send private message
mark



Joined: 07 Jan 2007
Posts: 1000

PostPosted: Fri Jul 20, 2007 10:07 pm    Post subject: Reply with quote

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
View user's profile Send private message
shaggydog97



Joined: 18 Jul 2007
Posts: 10

PostPosted: Mon Jul 23, 2007 2:54 pm    Post subject: Reply with quote

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
View user's profile Send private message
mark



Joined: 07 Jan 2007
Posts: 1000

PostPosted: Mon Jul 23, 2007 3:13 pm    Post subject: Reply with quote

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
View user's profile Send private message
shaggydog97



Joined: 18 Jul 2007
Posts: 10

PostPosted: Mon Jul 23, 2007 4:11 pm    Post subject: Reply with quote

thanks
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    PEAR Forum Forum Index -> Structures All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



PEAR Forum topic RSS feed 
Powered by phpBB © 2001, 2005 phpBB Group

Provided by Ministry of Web developement

'Actiemonitor' online projectmanagement software