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