| View previous topic :: View next topic |
| Author |
Message |
Mungbeans
Joined: 10 Jan 2007 Posts: 30 Location: Sydney, Australia
|
Posted: Tue Mar 27, 2007 4:27 am Post subject: Structures and DataObjects |
|
|
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 |
|
 |
Mungbeans
Joined: 10 Jan 2007 Posts: 30 Location: Sydney, Australia
|
Posted: Tue Mar 27, 2007 6:46 am Post subject: |
|
|
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 |
|
 |
Mungbeans
Joined: 10 Jan 2007 Posts: 30 Location: Sydney, Australia
|
Posted: Tue Mar 27, 2007 9:14 am Post subject: |
|
|
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 |
|
 |
mark

Joined: 07 Jan 2007 Posts: 1003
|
Posted: Tue Mar 27, 2007 10:51 am Post subject: |
|
|
| 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 |
|
 |
itp
Joined: 01 Jul 2007 Posts: 10
|
Posted: Sun Jul 01, 2007 6:20 pm Post subject: |
|
|
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 |
|
 |
itp
Joined: 01 Jul 2007 Posts: 10
|
Posted: Sun Jul 01, 2007 6:27 pm Post subject: |
|
|
| 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 |
|
 |
mark

Joined: 07 Jan 2007 Posts: 1003
|
Posted: Sun Jul 01, 2007 6:59 pm Post subject: |
|
|
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 |
|
 |
itp
Joined: 01 Jul 2007 Posts: 10
|
Posted: Mon Jul 02, 2007 12:34 am Post subject: |
|
|
| Code: | | Unknown Renderer driver. Please specify an existing driver |
|
|
| Back to top |
|
 |
mark

Joined: 07 Jan 2007 Posts: 1003
|
|
| Back to top |
|
 |
itp
Joined: 01 Jul 2007 Posts: 10
|
Posted: Mon Jul 02, 2007 3:49 pm Post subject: |
|
|
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 |
|
 |
|