[ Index ]
 

Code source de Dolibarr 2.0.1

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/htdocs/energie/ -> EnergieGroupe.class.php (source)

   1  <?php
   2  /* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
   3   *
   4   * This program is free software; you can redistribute it and/or modify
   5   * it under the terms of the GNU General Public License as published by
   6   * the Free Software Foundation; either version 2 of the License, or
   7   * (at your option) any later version.
   8   *
   9   * This program is distributed in the hope that it will be useful,
  10   * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12   * GNU General Public License for more details.
  13   *
  14   * You should have received a copy of the GNU General Public License
  15   * along with this program; if not, write to the Free Software
  16   * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  17   *
  18   * $Id: EnergieGroupe.class.php,v 1.1 2005/07/23 16:57:14 rodolphe Exp $
  19   * $Source: /cvsroot/dolibarr/dolibarr/htdocs/energie/EnergieGroupe.class.php,v $
  20   *
  21   */
  22  
  23  class EnergieGroupe
  24  {
  25    var $db ;
  26    var $user ;
  27  
  28    /**  \brief  Constructeur
  29     */
  30    function EnergieGroupe($DB, $user)
  31    {
  32      $this->db = $DB;
  33      $this->user = $user;
  34    }
  35  
  36    /** 
  37     * Lecture
  38     *
  39     */
  40    function fetch ($id)
  41    {
  42      $sql = "SELECT c.rowid, c.libelle";
  43      $sql .= " FROM ".MAIN_DB_PREFIX."energie_groupe as c";
  44      $sql .= " WHERE c.rowid = ".$id;
  45      
  46      $resql = $this->db->query($sql) ;
  47      
  48      if ( $resql )
  49        {
  50      $obj = $this->db->fetch_object($resql);
  51      
  52      $this->id              = $obj->rowid;
  53      $this->libelle         = $obj->libelle;
  54      
  55      $this->db->free();    
  56      return 0;
  57        }
  58      else
  59        {
  60      dolibarr_syslog("EnergieGroupe::fetch Erreur");
  61      return -1;
  62        }
  63    }
  64  
  65    /** 
  66     * Creation
  67     *
  68     */
  69    function Create ($libelle)
  70    {
  71      $sql  = "INSERT INTO ".MAIN_DB_PREFIX."energie_groupe";
  72      $sql .= " (libelle, datec, fk_user_author, note)";
  73      $sql .= " VALUES (";
  74      $sql .= "'".trim($libelle)."'";
  75      $sql .= ",now()";
  76      $sql .= ",'".$this->user->id."'";
  77      $sql .= ",'".$libelle."');";
  78  
  79      $resql = $this->db->query($sql) ;
  80  
  81      if ( $resql )
  82        {
  83      $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."energie_groupe");
  84  
  85      return 0;
  86        }
  87      else
  88        {
  89      dolibarr_syslog("EnergieGroupe::Create Erreur 1");
  90      dolibarr_syslog($this->db->error());
  91      return -1;
  92        }
  93    }
  94  }
  95  ?>


Généré le : Mon Nov 26 12:29:37 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics