Bonjour, j'ai tenté d'utiliser PhpMyOject tout à l'heure.
Je l'utilise avec une base PostgreSQL, mais meme avec un programme tout simple, je n'arrive pas a l'utiliser.
Mon code, tout simple :
Si j'utilise le driver pgsql, j'obtiens :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10 require_once("core/PMO_MyController.php"); $controler = new PMO_MyController(); $map = $controler->queryController("SELECT * FROM articles ORDER BY date_crea LIMIT 10; "); while ($result = $map->fetchMap()){ $article = $result['article']; echo("<h2>".$article->titre."</h2>"); echo($article->texte); }
En utilisant pdo, ceci :
Code : Sélectionner tout - Visualiser dans une fenêtre à part <h2></h2>
J'ai essayé de voir le contenu de $table avant le foreach :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5 Warning: Invalid argument supplied for foreach() in /home/fabien/public_html/pmo/core/PMO_MyController.php on line 48 Warning: Invalid argument supplied for foreach() in /home/fabien/public_html/pmo/core/PMO_MyObject.php on line 40 Warning: Invalid argument supplied for foreach() in /home/fabien/public_html/pmo/core/PMO_MyController.php on line 54
Avec pdo :
Avec pgsql :
Code : Sélectionner tout - Visualiser dans une fenêtre à part PMO_MyTable Object ( [table_name:protected] => articles [table_pk:protected] => [table_attribute:protected] => Array ( ) )
Voyant, ca, j'ai rajouté un print_r($map) entre le queryController et le while dans mon code.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49 PMO_MyTable Object ( [table_name:protected] => articles [table_pk:protected] => Array ( [0] => id_article ) [table_attribute:protected] => Array ( [id_article] => Array ( [Type] => alnum [Null] => [Key] => PRI [Default] => [Extra] => ) [texte] => Array ( [Type] => alnum [Null] => [Key] => NULL [Default] => [Extra] => ) [titre] => Array ( [Type] => alnum [Null] => [Key] => NULL [Default] => [Extra] => ) [date_crea] => Array ( [Type] => alnum [Null] => [Key] => NULL [Default] => [Extra] => ) ) )
On voit que l'article est bien récupéré, mais il ne s'affiche pas après.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 PMO_MyMap Object ( [map:protected] => Array ( [0] => Array ( [articles] => PMO_MyObject Object ( [object_id:protected] => 0 [object_table:protected] => PMO_MyTable Object ( //Comme au dessus... ) [object_attribute:protected] => Array ( [id_article] => 1 [texte] => Ceci est un article de test. <b>A ignorer</b> [titre] => Article test [date_crea] => 2007-10-14 21:36:10.062253 ) [object_linked:protected] => Array ( ) [object_new:protected] => 1 ) ) ) )
Donc voila, je cherche comment faire pour faire marcher ca.
Partager