Précédent   Forum du club des développeurs et IT Pro > PHP > PHP & SGBD > PHP & Oracle
PHP & Oracle Forum d'entraide sur Oracle avec PHP. Avant de poster -> FAQ Oracle et Cours Oracle
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse
 
Outils de la discussion
Publicité
'
Vieux 13/01/2012, 10h26   #1
H.ile
Membre du Club
 
Avatar de H.ile
 
Architecte de système d'information
Inscription : janvier 2008
Messages : 112
Détails du profil
Informations personnelles :
Âge : 33
Localisation : Macao

Informations professionnelles :
Activité : Architecte de système d'information

Informations forums :
Inscription : janvier 2008
Messages : 112
Points : 45
Points : 45
Par défaut Instancier une classe pour chaque résultat avec OCI_

aloha
Je définis ma classe :
Code :
1
2
3
4
5
6
<?php
class AutoCompletionCPVille {
	public $CodeInsee;
	public $Nom;
}
?>
Merci à x zolezzi pour son tuto sur l'autocomplétion.
Utilisant oracle, je passe plutôt par de l'OCI. Je récupère mon résultat de requête sous forme de tableau, mais je ne sais pas comment instancier chacun de mes résultats.

Comment faire ?

D'avance merci,

Ci après mon code :
Code :
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?php
error_reporting(E_ALL || E_NOTICE);
require_once('./AutoCompletionCPVille.class.php');
 
function select_to_array($connexion, $select) 
		{
			// Crée un tableau, un curseur, compte les colonnes,
			// fait le fetch en insérant dans le tableau.
			$myResults = array();
			// ora_do analyse (ora_parse) $query, l'exécute (ora_exec)
			// et lit la première ligne du résultat (ora_fetch).
			$statementID = oci_parse($connexion, $select);
			$executeResult = oci_execute($statementID);
			while (($row = oci_fetch_array($statementID, OCI_ASSOC))) {
			   array_push($myResults, $row);
			}
			oci_free_statement($statementID);
			return $myResults;
		}
 
//Initialisation de la liste
$list = array();
 
//Connexion Oracle
$base = "SIGE";
try
{
//echo 'bob';
    $ora_connSIGE = oci_connect("*****","$$$$$",$base);	
}
catch (Exception $ex)
{
    echo $ex->getMessage();
}
 
//Construction de la requete
$strQuery = "SELECT CO_INSEE CodeInsee, NOM Nom FROM BT_COMMU WHERE ";
if (isset($_POST["codeInsee"]))
{
    $strQuery .= "CO_INSEE LIKE :codeInsee ";
}
else
{
    $strQuery .= "NOM LIKE :ville ";
}
$strQuery .= "AND DEPART = 'MARNE' ";
 
//Limite
if (isset($_POST["maxRows"]))
{
    $strQuery .= "LIMIT 0, :maxRows";
}
 
if (isset($_POST["co_insee"]))
{
    $value = $_POST["co_insee"]."%";
	oci_bind_by_name($statementID, ":codeInsee", $value);
 
}
else
{
    $value = $_POST["ville"]."%";
	oci_bind_by_name($statementID, ":ville", $value);	
}
//Limite
if (isset($_POST["maxRows"]))
{
    $valueRows = intval($_POST["maxRows"]);
	oci_bind_by_name($statementID, ":maxRows", $value);
}
 
$list = select_to_array($ora_connSIGE, $strQuery);
 
echo json_encode($list);
?>
H.ile est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 13/01/2012, 10h28   #2
stealth35
Modérateur
 
Inscription : septembre 2010
Messages : 7 958
Détails du profil
Informations forums :
Inscription : septembre 2010
Messages : 7 958
Points : 9 508
Points : 9 508
avec PDO tu peux ça simplement
__________________
http://blog.stealth35.com/
stealth35 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 13/01/2012, 13h43   #3
H.ile
Membre du Club
 
Avatar de H.ile
 
Architecte de système d'information
Inscription : janvier 2008
Messages : 112
Détails du profil
Informations personnelles :
Âge : 33
Localisation : Macao

Informations professionnelles :
Activité : Architecte de système d'information

Informations forums :
Inscription : janvier 2008
Messages : 112
Points : 45
Points : 45
J'essaie :
Code :
1
2
3
4
5
6
7
8
9
10
11
 
try
{
	$ora_connSIGE = new PDO("oci:dbname=SIGE","****","$$$$$");
	echo 'bob';
}
catch (Exception $ex)
{
	echo 'bob2';
    echo $ex->getMessage();
}
Mais j'obtiens :
Citation:
Fatal error: Class 'PDO' not found in ... on line 13
Mon admin me dit que les librairies PDO sont bien installées, et que le pilote oracle aussi.

Une idée ?

D'avance, (re)merci
H.ile est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 13/01/2012, 13h46   #4
stealth35
Modérateur
 
Inscription : septembre 2010
Messages : 7 958
Détails du profil
Informations forums :
Inscription : septembre 2010
Messages : 7 958
Points : 9 508
Points : 9 508
fais un phpinfo tu verra bien si il a menti ou pas
__________________
http://blog.stealth35.com/
stealth35 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 13/01/2012, 13h49   #5
H.ile
Membre du Club
 
Avatar de H.ile
 
Architecte de système d'information
Inscription : janvier 2008
Messages : 112
Détails du profil
Informations personnelles :
Âge : 33
Localisation : Macao

Informations professionnelles :
Activité : Architecte de système d'information

Informations forums :
Inscription : janvier 2008
Messages : 112
Points : 45
Points : 45
huMMM;
j'ai ça :
Citation:
zend.ze1_compatibility_mode Off Off
C'est ce que je devais chercher ?
mais j'ai aussi :
...--with-pdo-oci=D:\php-sdk\oracle\instantclient10\sdk,shared" "--with-oci8=D:\php-sdk\oracle\instantclient10\sdk,shared"
H.ile est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 13/01/2012, 13h52   #6
stealth35
Modérateur
 
Inscription : septembre 2010
Messages : 7 958
Détails du profil
Informations forums :
Inscription : septembre 2010
Messages : 7 958
Points : 9 508
Points : 9 508
Regarde dans la section PDO, si y'en a pas c'est qu'il n'est pas activé
__________________
http://blog.stealth35.com/
stealth35 est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse
Outils de la discussion

Navigation rapide


Fuseau horaire GMT +2. Il est actuellement 22h02.


 
 
 
 
Partenaires

Hébergement Web