Page 1 sur 1

[PEAR], package datagrid

Posté : 25 janv. 2011, 23:23
par ferv21
Bonjour
J'utilise Pear afin de comprendre le fonctionnement de ce framework, j'essaye d'utilise le package Structures_DataGrid afin d'afficher un datagrid, le code à l'aide d'être bon, en revanche il n'y a rien qui s'affiche sur ma page.
Voici le code:
<?php
set_include_path(get_include_path() . ";c:\wamp\bin\php\php5.3.5\PEAR" );
require_once 'DB.php';
require_once 'Structures/DataGrid.php';
$options = array('dsn' => 'mysql://root:@localhost/mysql');
$db =& DB::connect('mysql://root:@localhost/mysql');
if(DB::isError($db)){
 die($db->getMessage());	
} 

$datagrid1 = new Structures_DataGrid();
$test = $datagrid1->bind('SELECT * FROM help_category',$options); 

if (DB::isError($test)) {
    echo $test->getMessage(); 
}
$datagrid1->render();
?>
voila est ce que j'ai oublier d'installer un autre package?
Cordialement

Re: [PEAR], package datagrid

Posté : 25 janv. 2011, 23:31
par stealth35
PEAR commence a être bien vieux, rien que la syntaxe et les librairies utilise dans ton exemple sont obsolètes, apres si rien ne s'affiche : est ce que la gestion des erreurs de ton PHP est activée ? (display_errors et error_reporting)

Re: [PEAR], package datagrid

Posté : 25 janv. 2011, 23:35
par ferv21
Salut stealth,
oui donc voici ce que j trouve dans mon php.ini

; display_errors
; Default Value: On
; Development Value: On
; Production Value: Off

; display_startup_errors
; Default Value: Off
; Development Value: On
; Production Value: Off

; error_reporting
; Default Value: E_ALL & ~E_NOTICE
; Development Value: E_ALL | E_STRICT
; Production Value: E_ALL & ~E_DEPRECATED

Re: [PEAR], package datagrid

Posté : 25 janv. 2011, 23:46
par stealth35
Salut stealth,
oui donc voici ce que j trouve dans mon php.ini

; display_errors
; Default Value: On
; Development Value: On
; Production Value: Off

; display_startup_errors
; Default Value: Off
; Development Value: On
; Production Value: Off

; error_reporting
; Default Value: E_ALL & ~E_NOTICE
; Development Value: E_ALL | E_STRICT
; Production Value: E_ALL & ~E_DEPRECATED
c'est les commentaire, ca normalement c'est plus loin.
mais ton code devrait plus ressembler a ca :
require_once 'DB.php';
require_once 'Structures/DataGrid.php';
$options = array('dsn' => 'mysql://root@localhost/test');

$datagrid = new Structures_DataGrid();
$test = $datagrid->bind('SELECT * FROM test', $options);

if (PEAR::isError($test))
{ 
    exit($test->getMessage());
}  

$test = $datagrid->render();  

if (PEAR::isError($test))
{ 
    exit($test->getMessage());
}

Re: [PEAR], package datagrid

Posté : 25 janv. 2011, 23:57
par ferv21
J'ai essayer ton code, rien ne s'affiche par contre j'ai ce message d'erreur généré par PEAR:
Unknown DataSource driver. Please specify an existing driver.

Donc a priori il faut installer le driver, mais comment dois-je faire?
Merci

Re: [PEAR], package datagrid

Posté : 26 janv. 2011, 00:00
par stealth35
J'ai essayer ton code, rien ne s'affiche par contre j'ai ce message d'erreur généré par PEAR:
Unknown DataSource driver. Please specify an existing driver.

Donc a priori il faut installer le driver, mais comment dois-je faire?
Merci
il faut installer Structures_DataGrid_DataSource_DB

donc :
pear install Structures_DataGrid_DataSource_DB-beta
et au debut de ton code fait :
ini_set('display_errors', 1);
error_reporting(-1);
et j'insiste sur le fait que PEAR c'est pour php 4

Re: [PEAR], package datagrid

Posté : 26 janv. 2011, 00:33
par ferv21
Merci pour ton aide, oui j'essaye tant bien que mal de maitriser un bon framework mais as tu autre chose que pear a me conseiller.

PS: quand j'ai ajouter les deux lignes de codes J'ai plein d'erreur du genre:
( ! ) Strict standards: Non-static method PEAR::raiseError() should not be called statically, assuming $this from incompatible context in C:\wamp\bin\php\php5.3.5\PEAR\Structures\DataGrid.php on line 1538
Call Stack

( ! ) Strict standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in C:\wamp\bin\php\php5.3.5\PEAR\Structures\DataGrid.php on line 448
ect...

Re: [PEAR], package datagrid

Posté : 26 janv. 2011, 00:44
par stealth35
Merci pour ton aide, oui j'essaye tant bien que mal de maitriser un bon framework mais as tu autre chose que pear a me conseiller.

PS: quand j'ai ajouter les deux lignes de codes J'ai plein d'erreur du genre:
( ! ) Strict standards: Non-static method PEAR::raiseError() should not be called statically, assuming $this from incompatible context in C:\wamp\bin\php\php5.3.5\PEAR\Structures\DataGrid.php on line 1538
Call Stack

( ! ) Strict standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in C:\wamp\bin\php\php5.3.5\PEAR\Structures\DataGrid.php on line 448
ect...
c'est parce que c'est du PHP 4, donc il aime pas trop, mais surprime les lignes que je t'ai dis, et ressaye