Re: Structures_DataGrid upgrade breaking $page?

From: Date: Wed, 25 Jan 2006 13:22:08 +0000
Subject: Re: Structures_DataGrid upgrade breaking $page?
Groups: php.pear.general 
Request: Send a blank email to pear-general+get-22683@lists.php.net to get a copy of this message
Here is the code requested: Sorry if the code sucks, I hope it makes sense, and feel free to tell me if there is a better way :-) Thanks. Also, it should be noted I'm using 0.6.3 with DB_DO 1.8.2 in case that makes any difference. First, my extended form where I had to do the workaround: class myDataGrid extends Structures_Datagrid { function myDataGrid($limit = null, $page = 0) { if(isset($_GET['page'])) { // this is 'if' section I had to add. $page = $_GET['page']; } parent::Structures_DataGrid($limit, $page); //$this->renderer->setTableHeaderAttributes(array('bgcolor' => 'CCCCCC')); $this->renderer->setTableHeaderAttributes(array('class' => 'datagridheader')); $this->renderer->setTableEvenRowAttributes(array('class' => 'datagridevenrow')); $this->renderer->setTableOddRowAttributes(array('class' => 'datagridoddrow')); $this->renderer->setTableAttribute('cellspacing', '0'); $this->renderer->setTableAttribute('cellpadding', '2'); $this->renderer->setTableAttribute('class', 'datagrid'); $this->renderer->sortIconASC = '<img src="images\Icon_ATOZ.gif" \>'; $this->renderer->sortIconDESC = '<img src="images\Icon_ZTOA.gif" \>'; } } Now the code... this is one example, even though every page that uses similar code had the same problem. $table = 'liveuser_users'; $_GET['table'] = $table; //set this since $table was set manually in this page $missionnotes = DB_DataObject::factory($table); $missionkey = $missionnotes->keys(); $linkedtables = $missionnotes->links(); //get a list of all linked tables if(isset($linkedtables)) { foreach($linkedtables as $link => $table) { $tablename = explode(":", $table); $temp = DB_DataObject::factory($tablename[0]); $missionnotes->selectAs($temp); $missionnotes->joinAdd($temp); $tempkeys = ($temp->keys()); $linkedfields[$link] = $temp->fb_linkDisplayFields; } } if(isset($missionnotes->fb_fieldLabels)) { $fieldstorender = ($missionnotes->fb_fieldLabels); } elseif(isset($missionnotes->fb_fieldsToRender)) { $fieldstorender = ($missionnotes->fb_fieldsToRender); } else { echo '<h2>There are no "fb_fieldLabels" or "fb_fieldsToRender" array in the table '.$_GET['table'].' dataobject</h2>'; die; } if($missionnotes->find()) { while($missionnotes->fetch()) { $missionnotes->getLinks(); $missionarray[] = $missionnotes->toArray(); } } $webself = ltrim($_SERVER['PHP_SELF'], "/"); $dg =& new myDataGrid(20); if(isset($missionarray)) { $dg->bind($missionarray); } foreach($fieldstorender as $num => $searchkey) { if(isset($linkedfields)) { if(array_key_exists($num, $linkedfields)) { $num = $linkedfields[$num][0]; } } $dg->addColumn(new Structures_DataGrid_Column($searchkey, $num, $num, array('align' => 'center'))); } $dg->addColumn(new Structures_DataGrid_Column('Edit Record', null, null, array('width' => '10%', 'align' => 'center'), null, 'printEditLink()')); $dg->addColumn(new Structures_DataGrid_Column('Delete Record', null, null, array('width' => '10%'), null, 'deleteRecord()')); $dg->render(); echo $dg->renderer->getPaging(); that's the code that gives me all the problems. As soon as I added that if statement in the myDataGrid everything worked just fine. Thanks for all the help, and sorry if this doesn't appear under the prior postings, I can't subscribe to newsgroups or anything like that at work. Zane

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