1 |
<?php
|
1 |
<?php
|
2 |
/*vim: set expandtab tabstop=4 shiftwidth=4: */
|
2 |
/*vim: set expandtab tabstop=4 shiftwidth=4: */
|
3 |
// +------------------------------------------------------------------------------------------------------+
|
3 |
// +------------------------------------------------------------------------------------------------------+
|
4 |
// | PHP version 4.1 |
|
4 |
// | PHP version 4.1 |
|
5 |
// +------------------------------------------------------------------------------------------------------+
|
5 |
// +------------------------------------------------------------------------------------------------------+
|
6 |
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) |
|
6 |
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) |
|
7 |
// +------------------------------------------------------------------------------------------------------+
|
7 |
// +------------------------------------------------------------------------------------------------------+
|
8 |
// | This library is free software; you can redistribute it and/or |
|
8 |
// | This library is free software; you can redistribute it and/or |
|
9 |
// | modify it under the terms of the GNU Lesser General Public |
|
9 |
// | modify it under the terms of the GNU Lesser General Public |
|
10 |
// | License as published by the Free Software Foundation; either |
|
10 |
// | License as published by the Free Software Foundation; either |
|
11 |
// | version 2.1 of the License, or (at your option) any later version. |
|
11 |
// | version 2.1 of the License, or (at your option) any later version. |
|
12 |
// | |
|
12 |
// | |
|
13 |
// | This library is distributed in the hope that it will be useful, |
|
13 |
// | This library is distributed in the hope that it will be useful, |
|
14 |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
14 |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
15 |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
16 |
// | Lesser General Public License for more details. |
|
16 |
// | Lesser General Public License for more details. |
|
17 |
// | |
|
17 |
// | |
|
18 |
// | You should have received a copy of the GNU Lesser General Public |
|
18 |
// | You should have received a copy of the GNU Lesser General Public |
|
19 |
// | License along with this library; if not, write to the Free Software |
|
19 |
// | License along with this library; if not, write to the Free Software |
|
20 |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
20 |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
21 |
// +------------------------------------------------------------------------------------------------------+
|
21 |
// +------------------------------------------------------------------------------------------------------+
|
22 |
// CVS : $Id: SQL_manipulation.fonct.php,v 1.1 2004-06-15 10:13:26 jpm Exp $
|
22 |
// CVS : $Id: SQL_manipulation.fonct.php,v 1.2 2004-10-21 15:17:19 alex Exp $
|
23 |
/**
|
23 |
/**
|
24 |
* Bibliothèque de fonctions liées au SQL
|
24 |
* Bibliothèque de fonctions liées au SQL
|
25 |
*
|
25 |
*
|
26 |
* Contient des fonctions permettant d'automatiser certaine requête SQL.
|
26 |
* Contient des fonctions permettant d'automatiser certaine requête SQL.
|
27 |
*
|
27 |
*
|
28 |
*@package SQL
|
28 |
*@package SQL
|
29 |
//Auteur original :
|
29 |
//Auteur original :
|
30 |
*@author Jean-Pascal MILCENT <jpm@tela-botanica.org>
|
30 |
*@author Jean-Pascal MILCENT <jpm@tela-botanica.org>
|
31 |
//Autres auteurs :
|
31 |
//Autres auteurs :
|
32 |
*@author Aucun
|
32 |
*@author Aucun
|
33 |
*@copyright Tela-Botanica 2000-2004
|
33 |
*@copyright Tela-Botanica 2000-2004
|
34 |
*@version $Revision: 1.1 $ $Date: 2004-06-15 10:13:26 $
|
34 |
*@version $Revision: 1.2 $ $Date: 2004-10-21 15:17:19 $
|
35 |
// +------------------------------------------------------------------------------------------------------+
|
35 |
// +------------------------------------------------------------------------------------------------------+
|
36 |
*/
|
36 |
*/
|
37 |
|
37 |
|
38 |
// +------------------------------------------------------------------------------------------------------+
|
38 |
// +------------------------------------------------------------------------------------------------------+
|
39 |
// | LISTE de FONCTIONS |
|
39 |
// | LISTE de FONCTIONS |
|
40 |
// +------------------------------------------------------------------------------------------------------+
|
40 |
// +------------------------------------------------------------------------------------------------------+
|
41 |
/** Fonction SQL_obtenirNouveauId()- Retourne le prochain identifiant numérique libre d'une table.
|
41 |
/** Fonction SQL_obtenirNouveauId()- Retourne le prochain identifiant numérique libre d'une table.
|
42 |
*
|
42 |
*
|
43 |
* On passe en paramètre le nom de la table, le nom du champ cotnenant la clé et l'objet PEAR DB
|
43 |
* On passe en paramètre le nom de la table, le nom du champ cotnenant la clé et l'objet PEAR DB
|
44 |
*
|
44 |
*
|
45 |
* @param mixed handler de connexion
|
45 |
* @param mixed handler de connexion
|
46 |
* @param string Nom de la table
|
46 |
* @param string Nom de la table
|
47 |
* @param string Nom du champ identifiant.
|
47 |
* @param string Nom du champ identifiant.
|
48 |
* @return mixed la nouvelle valeur de clé pouvant être utilisé ou false en cas d'erreur sql.
|
48 |
* @return mixed la nouvelle valeur de clé pouvant être utilisé ou false en cas d'erreur sql.
|
49 |
*/
|
49 |
*/
|
50 |
|
50 |
|
51 |
function SQL_obtenirNouveauId($db, $table, $colonne_identifiant)
|
51 |
function SQL_obtenirNouveauId(&$db, $table, $colonne_identifiant)
|
52 |
{
|
52 |
{
|
53 |
$requete = 'SELECT MAX('.$colonne_identifiant.') AS maxi FROM '.$table;
|
53 |
$requete = 'SELECT MAX('.$colonne_identifiant.') AS maxi FROM '.$table;
|
54 |
$resultat = $db->query($requete);
|
54 |
$resultat = $db->query($requete);
|
55 |
if (DB::isError($resultat) || $resultat->numRows() > 1) {
|
55 |
if (DB::isError($resultat) || $resultat->numRows() > 1) {
|
56 |
return false;
|
56 |
return false;
|
57 |
}
|
57 |
}
|
58 |
|
58 |
|
59 |
$ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT);
|
59 |
$ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT);
|
60 |
return $ligne->maxi + 1;
|
60 |
return $ligne->maxi + 1;
|
61 |
}
|
61 |
}
|
62 |
|
62 |
|
63 |
|
63 |
|
64 |
/* +--Fin du code ----------------------------------------------------------------------------------------+
|
64 |
/* +--Fin du code ----------------------------------------------------------------------------------------+
|
65 |
*
|
65 |
*
|
66 |
* $Log: not supported by cvs2svn $
|
66 |
* $Log: not supported by cvs2svn $
|
- |
|
67 |
* Revision 1.1 2004/06/15 10:13:26 jpm
|
- |
|
68 |
* Intégration dans Papyrus.
|
- |
|
69 |
*
|
67 |
* Revision 1.1 2004/04/28 11:38:54 jpm
|
70 |
* Revision 1.1 2004/04/28 11:38:54 jpm
|
68 |
* Ajout d'un fichier de fonctions de manipulation sql.
|
71 |
* Ajout d'un fichier de fonctions de manipulation sql.
|
69 |
*
|
72 |
*
|
70 |
*
|
73 |
*
|
71 |
* +-- Fin du code ----------------------------------------------------------------------------------------+
|
74 |
* +-- Fin du code ----------------------------------------------------------------------------------------+
|
72 |
*/
|
75 |
*/
|
73 |
?>
|
76 |
?>
|