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 
Structures and DataObjects

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



Joined: 10 Jan 2007
Posts: 30
Location: Sydney, Australia

PostPosted: Tue Mar 27, 2007 4:27 am    Post subject: Structures and DataObjects Reply with quote

I am using the DataObjects class with Structures for the first time and am having trouble following the tutorial at:
http://www.samalyse.com/code/pear/dgdo/index.php

Here is the code so far:

Code:

//required PEAR modules
require_once( "PEAR.php");
require_once( "HTML/Table.php");
require_once('Structures/DataGrid.php');
require_once('DB/DataObject.php');

class do_product extends DB_DataObject {
    var $__table = "mos_gs_product";
   
   var $productid;
   var $name;
   var $description;
   var $price;
   var $date;
   var $last_update;
}


/* Database and DataObject setup */
$dataobjectOptions = &PEAR::getStaticProperty("DB_DataObject","options");
$dbString ="mysql://".$user.":".$password."@".$host."/".$db;
$dataobjectOptions["database"] =  $dbString;
$dataobjectOptions["proxy"] = "full";
   
/* Instantiate */
$dataobject = new do_product();
$datagrid =& new Structures_DataGrid(10); /* 10 rows per table */

/* Bind */
$datagrid->bind($dataobject);

/* Output */
$datagrid->render();



When I run the code I don't get any errors but nothing at all prints out. How do I bug-fix this? I'm not sure if the problem is happening in DataObjects or the DataGrid.

My aim is that have a page where all the rows are printed out, with a form at the top for filtering the data.
Back to top
View user's profile Send private message
Mungbeans



Joined: 10 Jan 2007
Posts: 30
Location: Sydney, Australia

PostPosted: Tue Mar 27, 2007 6:46 am    Post subject: Reply with quote

I've gone through the fun process of having all the DataObjects and classes set up in their own directory and now DataObjects works well on its own. However, when I try to link it into the DataGrid still nothing happens. Eg:

Code:

   /* Instantiate */
   $dataobject = DB_DataObject::factory( 'mos_gs_product' );
   $datagrid =& new Structures_DataGrid(10); /* 10 rows per table */

   /* Bind */
   $datagrid->bind($dataobject);

   /* Output */
   $datagrid->render();


Nothing is rendering.
Back to top
View user's profile Send private message
Mungbeans



Joined: 10 Jan 2007
Posts: 30
Location: Sydney, Australia

PostPosted: Tue Mar 27, 2007 9:14 am    Post subject: Reply with quote

This error trapping:
Code:

   $test = $datagrid->bind($product);
   if (PEAR::isError($test)) {
       echo $test->getMessage();
   }


Produces this error message:
Code:

Unknown DataSource driver. Please specify an existing driver.
Back to top
View user's profile Send private message
mark



Joined: 07 Jan 2007
Posts: 1003

PostPosted: Tue Mar 27, 2007 10:51 am    Post subject: Reply with quote

Mungbeans wrote:
This error trapping:
Code:

   $test = $datagrid->bind($product);
   if (PEAR::isError($test)) {
       echo $test->getMessage();
   }


Produces this error message:
Code:

Unknown DataSource driver. Please specify an existing driver.


You need to install Structures_DataGrid_DataSource_DataObject.
Back to top
View user's profile Send private message
itp



Joined: 01 Jul 2007
Posts: 10

PostPosted: Sun Jul 01, 2007 6:20 pm    Post subject: Reply with quote

Another pear newbie here & I am having the same issue.

Code:
Unable to determine the data source type. You may want to explicitly... 


I unzipped datasource library and others that were required. see image & full listing
http://tinyurl.com/2pjefv
http://tinyurl.com/2o43nz

Appreciate any assistance...

Code:

top of page <br>
<?php
/* Includes */   

// show all errors
error_reporting(E_ALL & ~E_NOTICE);
ini_set('display_errors', '5');

require_once "PEAR.php";
define("DB_DATAOBJECT_NO_OVERLOAD",true); /* This is needed for some buggy versions of PHP4 */
require_once "DB/DataObject.php";
require_once "Structures/DataGrid.php";   

/* Database and DataObject setup */
$dataobjectOptions = &PEAR::getStaticProperty("DB_DataObject","options");
$dataobjectOptions["database"] =  "mysql://root:@localhost/homes";
$dataobjectOptions["proxy"] = "full";

class DataObject_Fruits extends DB_DataObject
{
    var $__table = "listings";
    var $code;
   var $town;
   var $price;
   var $bedrooms;
}

/* Instantiate */
$dataobject = new DataObject_Fruits();
$datagrid =& new Structures_DataGrid(5); /* 5 rows per table */

/* Bind */
 
 $test = $datagrid->bind($product);
   if (PEAR::isError($test)) {
       echo $test->getMessage();
   }

/* Output */
$datagrid->render();
 
?>

<br>bottom of page.
Back to top
View user's profile Send private message
itp



Joined: 01 Jul 2007
Posts: 10

PostPosted: Sun Jul 01, 2007 6:27 pm    Post subject: Reply with quote

Code:
 $test = $datagrid->bind($dataobject);
   if (PEAR::isError($test)) {
       echo $test->getMessage();
   }


Ooops that one was self-inflicted . Binding an undefined data object.
Now script completed flawlessly with no output at all. Any other error/message trapping that I could add? Other ideas?

Thanks again.
Back to top
View user's profile Send private message
mark



Joined: 07 Jan 2007
Posts: 1003

PostPosted: Sun Jul 01, 2007 6:59 pm    Post subject: Reply with quote

You should get some output if you add the following lines of code after the inclusion of PEAR.php:

Code:

error_reporting(E_ALL);
ini_set('display_errors', 1);
PEAR::setErrorHandling(PEAR_ERROR_DIE);
Back to top
View user's profile Send private message
itp



Joined: 01 Jul 2007
Posts: 10

PostPosted: Mon Jul 02, 2007 12:34 am    Post subject: Reply with quote

Code:
Unknown Renderer driver. Please specify an existing driver
Back to top
View user's profile Send private message
mark



Joined: 07 Jan 2007
Posts: 1003

PostPosted: Mon Jul 02, 2007 9:17 am    Post subject: Reply with quote

itp wrote:
Code:
Unknown Renderer driver. Please specify an existing driver


Install Structures_DataGrid_Renderer_HTMLTable. It's described here:
http://pear.php.net/manual/en/package.structures.structures-datagrid.installation.php
Back to top
View user's profile Send private message
itp



Joined: 01 Jul 2007
Posts: 10

PostPosted: Mon Jul 02, 2007 3:49 pm    Post subject: Reply with quote

Re-installed Pear and all required modules and... bang it all worked first shot. This is an amazing toolset!!!!

I would love to see what others are doing with datagrid!
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