Files
le-matelot/client/plugins/combidecli/CombidecliProduit.class.php
2020-01-27 08:56:08 +01:00

92 lines
3.3 KiB
PHP

<?php
/*************************************************************************************/
/* */
/* Thelia - Plugin de combinaison des déclinaisons */
/* */
/* Copyright (c) Franck Allimant, 2011 */
/* email : franck.allimant@cqfdev.fr */
/* web : http://www.cqfdev.fr */
/* idée originale: Jean-Baptiste Billot (ottoroots@gmail.com) */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License, or */
/* (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program; if not, write to the Free Software */
/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/* */
/*************************************************************************************/
include_once(realpath(dirname(__FILE__)) . "/../../../classes/Baseobj.class.php");
class CombidecliProduit extends Baseobj
{
const TABLE = 'combidecliproduit';
public $id;
public $produit;
public $declinaison;
public $table = self::TABLE;
public $bddvars = array('id', 'produit', 'declinaison');
public function CombidecliProduit($id = false)
{
parent::Baseobj();
if ($id) $this->charger($id);
}
public static function init()
{
$query = 'CREATE TABLE IF NOT EXISTS '.self::TABLE.' (
id int(11) NOT NULL auto_increment,
produit int(11) NOT NULL,
declinaison int(11) NOT NULL,
PRIMARY KEY (id),
INDEX (produit)
) AUTO_INCREMENT=1 ;';
$result = mysql_query($query);
}
public static function destroy()
{
mysql_query('DROP TABLE ' . self::TABLE);
}
function charger_id($id)
{
$this->id = $id;
return parent::charger();
}
static function lister_par_produit($idproduit)
{
$arr = array();
$result = mysql_query("select * from ".self::TABLE." where produit=$idproduit");
while ($result && $obj = mysql_fetch_object($result, 'CombidecliProduit'))
{
$arr[] = $obj;
}
return $arr;
}
static function supprimer_par_produit($idproduit)
{
mysql_query("delete from ".self::TABLE." where produit=$idproduit");
}
}