Re: DataGrid_Column
| From: | Ian Warner | Date: | Sat, 30 Sep 2006 04:17:17 +0000 |
| Subject: | Re: DataGrid_Column | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-25305@lists.php.net to get a copy of this message | ||
Chris Boget wrote:
I'm trying to get the value of one of the columns in my table passed to nl2br for display. However, when the column value does get displayed, it shows up as Array. Here is how I'm adding my column to the datagrid: $datagrid = new Structures_DataGrid( 10 ) $datagrid->bind( $users ); $datagrid->addColumn(new Structures_DataGrid_Column('User', 'uid', 'uid')); $datagrid->addColumn(new Structures_DataGrid_Column('Comments', 'comments', 'comments', null, null, 'nl2br()')); echo $datagrid->render( DATAGRID_RENDER_TABLE ); nl2br is a string function so will not work on an array. Suprised you dindt get array to sting conversion warning. always in my code have this little snippet.echo '<pre>'; print_r($users); echo '</pre>'; just comment out when needed but invaluable sometime to just get a knowledge of what you are rendering. I also always limit my queries to 1 at the start to stop visious loops and keep it quick. Turn DO debug onto 1 also. Then if you are better than me create a little debug script append it in php.ini and add in all these little snippets - I had it once where all my queries on a page were evaluated using EXPLAIN .... and printed out for me - that was invaluable actually in opimisation, in fact I should get that going again :) Infact it wouuld be a nice debug option in DO - MDB2 - DB etc to be able to print out an EXPLAIN box within the script to optimise queries.
When it gets displayed, it shows the user column fine but the comments column has 'Array'. In Structures_DataGrid_Column, the formatter() method is running the call_user_func() on line 236 but I'm not sure if that's the one it should be using. Am I doing this wrong? Can I not use nl2br()? thnx, Chris