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 
add columns with row number +++ complex SQL-like statements

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



Joined: 01 Jul 2007
Posts: 10

PostPosted: Tue Jul 03, 2007 12:29 am    Post subject: add columns with row number +++ complex SQL-like statements Reply with quote

I am following the example in the FAQ that permit programmer to add column with row numbers.
However I get an error on the second parm:

Code:

Warning: Missing argument 2 for formatRowNumber() in C:\xampp\htdocs\itp\pear_05.php on line 27

Notice: Undefined variable: recordNumberStart in C:\xampp\htdocs\itp\pear_05.php on line 29


Can someone explain how this works?

...Also I would like to use a more complex SQL statement
(Select * from file where condition order by group by having...). Is this possible?

Code:

function formatRowNumber($params, $recordNumberStart)
{
    return $params['currRow'] + $recordNumberStart;
}

$datagrid->addColumn(
    new Structures_DataGrid_Column(
        '#',
        null,
        null,
        array('style' => 'text-align: right;'),
        null,
        'formatRowNumber',
        $datagrid->getCurrentRecordNumberStart()
    ));
 
Back to top
View user's profile Send private message
mark



Joined: 07 Jan 2007
Posts: 998

PostPosted: Tue Jul 03, 2007 10:07 am    Post subject: Re: add columns with row number +++ complex SQL-like stateme Reply with quote

itp wrote:
I am following the example in the FAQ that permit programmer to add column with row numbers.
However I get an error on the second parm:

Code:

Warning: Missing argument 2 for formatRowNumber() in C:\xampp\htdocs\itp\pear_05.php on line 27

Notice: Undefined variable: recordNumberStart in C:\xampp\htdocs\itp\pear_05.php on line 29


Hmm, would it be possible that you have an old version of Structures_DataGrid installed? The second argument for formatters was added IIRC in 0.7.0.

itp wrote:
...Also I would like to use a more complex SQL statement
(Select * from file where condition order by group by having...). Is this possible?


Sure. But you need to take care of the notes in the manual about wrong values for the numbers of rows in some cases. It is also explained there how you can avoid the wrong values.
Back to top
View user's profile Send private message
itp



Joined: 01 Jul 2007
Posts: 10

PostPosted: Tue Jul 03, 2007 1:44 pm    Post subject: Reply with quote

Structures modules are all freshly installed.

Code:
  pear.php.net  Structures_DataGrid  0.8.3  beta       
  pear.php.net  Structures_DataGrid_DataSource_Array  0.1.2  beta       
  pear.php.net  Structures_DataGrid_DataSource_DB  0.1.1  beta       
  pear.php.net  Structures_DataGrid_DataSource_DataObject  0.2.0  beta       
  pear.php.net  Structures_DataGrid_Renderer_HTMLTable  0.1.3  beta       
  pear.php.net  Structures_DataGrid_Renderer_Pager  0.1.2  beta 


It looks like I am calling function 'formatRowNumber' dynamically while making an instance of class Structures_DataGrid_Column. If so where are the 2 parms for 'formatRowNumber'?

Please bear with me, this is pretty new for me.

example is from Structures_DataGrid FAQ
http://www.go-pear.org/manual/en/package.structures.structures-datagrid.faq.php
Back to top
View user's profile Send private message
mark



Joined: 07 Jan 2007
Posts: 998

PostPosted: Tue Jul 03, 2007 5:17 pm    Post subject: Reply with quote

itp wrote:
Structures modules are all freshly installed.

Code:
  pear.php.net  Structures_DataGrid  0.8.3  beta       
  pear.php.net  Structures_DataGrid_DataSource_Array  0.1.2  beta       
  pear.php.net  Structures_DataGrid_DataSource_DB  0.1.1  beta       
  pear.php.net  Structures_DataGrid_DataSource_DataObject  0.2.0  beta       
  pear.php.net  Structures_DataGrid_Renderer_HTMLTable  0.1.3  beta       
  pear.php.net  Structures_DataGrid_Renderer_Pager  0.1.2  beta 


Okay, looks good. (But you should consider to uninstall the DB DataSource. It uses DB result objects which are not really performant.)

itp wrote:
It looks like I am calling function 'formatRowNumber' dynamically while making an instance of class Structures_DataGrid_Column. If so where are the 2 parms for 'formatRowNumber'?


$params (the first parameter) is generated by Structures_DataGrid (SDG). The second parameter is the value from the last parameter of the column constructur (here: $datagrid->getCurrentRecordNumberStart()).

I'm using the code from the example in my projects, and the code works as expected here.

Although you wrote that you have the current versions installed, are you sure that you don't include old SDG files from another directory? The second parameter for formatters is new (since IIRC 0.7.0), and the error message somehow indicates that this could be a problem with an old version.

itp wrote:
example is from Structures_DataGrid FAQ


I know, I'm the author of the example. Wink
Back to top
View user's profile Send private message
alex



Joined: 13 Sep 2006
Posts: 72

PostPosted: Tue Jul 03, 2007 5:22 pm    Post subject: Reply with quote

There may be a problem in your whole code. You should paste it ...

For the 2 parameters : 2nd is $datagrid->getCurrentRecordNumberStart() (gives a int according to the doc) and I would say first is internal.
Back to top
View user's profile Send private message
itp



Joined: 01 Jul 2007
Posts: 10

PostPosted: Wed Jul 04, 2007 5:47 am    Post subject: Reply with quote

I uninstalled the DB DataSource and made some changes.
Code is now generating column with row numbers, but with warnings.

here is list of code, modules installed & error warnings.
http://tinyurl.com/34k393

thanks,

ITP
Back to top
View user's profile Send private message
mark



Joined: 07 Jan 2007
Posts: 998

PostPosted: Wed Jul 04, 2007 9:10 am    Post subject: Reply with quote

itp wrote:
I uninstalled the DB DataSource and made some changes.
Code is now generating column with row numbers, but with warnings.

here is list of code, modules installed & error warnings.
http://tinyurl.com/34k393


Please use a service like http://phpfi.com/ for showing large pieces of code (advantages: no additional software required, syntax highliting).

You still seem to get the same warnings as before. Have you made sure that no old files get included? You can check that with get_included_files() [1].

[1] http://www.php.net/get_included_files
Back to top
View user's profile Send private message
itp



Joined: 01 Jul 2007
Posts: 10

PostPosted: Wed Jul 04, 2007 8:41 pm    Post subject: Reply with quote

Quote:
foreach ($included_files as $filename) {
echo "$filename\n";
}


at the end of my program gives me:

Quote:
C:\xampp\php\PEAR\PEAR.php
C:\xampp\php\PEAR\DB\DataObject.php
C:\xampp\php\PEAR\Structures\DataGrid.php
C:\xampp\php\PEAR\Structures\DataGrid\Column.php


The first is my program... Any culprits here?
Back to top
View user's profile Send private message
itp



Joined: 01 Jul 2007
Posts: 10

PostPosted: Wed Jul 04, 2007 10:12 pm    Post subject: Reply with quote

OK. I moved $datagrid->addColumn AFTER the $datagrid->bind and it works perfectly.
Back to top
View user's profile Send private message
mark



Joined: 07 Jan 2007
Posts: 998

PostPosted: Wed Jul 04, 2007 10:24 pm    Post subject: Reply with quote

itp wrote:
OK. I moved $datagrid->addColumn AFTER the $datagrid->bind and it works perfectly.


Strange that is *this* the solutuion, but it's of course nice to hear that the problem is solved anyway.
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