<?php
class membre {
public $id ;
public $nom ;
public $prenom;
public $adress;
public $email;
public $pseudo;
public $mp;
function load($id) {
$sql = " SELECT pseudo
FROM membre
WHERE ";
$sql .= "=" . tosql($id) ." LIMIT 1";
$this->db->query($sql);
$next_rec = $this->db->next_record();
$this->id = $this->db->f("id");
$this->nom = $this->db->f("nom");
$this->prenom= $this->db->f("prenom") ;
$this->adress= $this->db->f("adress") ;
$this->email= $this->db->f("email") ;
$this->pseudo= $this->db->f("pseudo") ;
$this->mp= $this->db->f("mp") ;
return $this->db->Record;
}
function insert() {
$sql = " INSERT INTO `tb_membre` (`nom`, `prenom`, `adress`, `pseudo`,'mp','email')
VALUES (" .
tosql($this->nom, "text"). ", " . tosql($this->adress, "text") .", " .
tosql($this->prenom, "text"). ", " . tosql($this->pseudo, "text") . ") ".
tosql($this->email, "text") . ", ".tosql ($this->mp,"text") ;
if($this->db->query($sql)) {
$this->emailid = mysql_insert_id();
return true;
}
return false;
}
function remove($id) {
$sql = " UPDATE `tb_membre` SET
pseudo = '" .$pseudo . "'
WHERE IDMid=" . tosql($id) . " LIMIT 1";
if ($this->db->query($sql)) {
return true;
}
return false;
}
function update($emailid) {
$sql = " UPDATE `tb_membre` SET
`nom` = " . tosql($this->nom, "text") . " ,
`prenom` = " . tosql($this->prenom , "text") . ",
`adress` = " . tosql($this->adress , "text") . ",
`pseudo` = " . tosql($this->pseudo, "text") . ",
'mp'=" . tosql ($this->mp, "text")."
'email'=".tosql($this->email,"text").",
WHERE `id` = " . tosql($id) . " LIMIT 1 ";
if ($this->db->query($sql)) {
return true;
}
return false;
}
function get_list() {
$where = " ";
if ($this->nom) {$where .= " AND nom LIKE " . tosql("%" . $this->nom . "%", "text"); }
if ($this->prenom) {$where .= " AND prenom = " . tosql($this->prenom , "text"); }
if ($this->adress) {$where .= " AND adress = " . tosql($this->adress, "text"); }
if ($this->email) {$where .= " AND email LIKE " . tosql("%" . $this->email . "%", "text"); }
if ($this->pseudo) {$where .= " AND pseudo LIKE " . tosql("%" . $this->pseudo . "%", "text"); }
if ($this->mp) {$where .= " AND mp LIKE " . tosql("%" . $this->mp . "%", "text"); }
$sql = " SELECT COUNT(*) FROM `tb_membre`
WHERE email IS NULL $where ";
$this->db->query($sql);
$next_rec = $this->db->next_record();
$this->total = $this->db->f(0);
$sql = "
SELECT * ,
FROM `tb_membre`
WHERE email IS NULL $where
ORDER BY c.display_order ASC ";
if ($this->rows !== '') {
$sql .= " LIMIT ";
if ($this->offset !== '') {
$sql .= $this->offset . ", " ;
}
$sql.= $this->rows;
}
$this->db->query($sql);
$next_rec = $this->db->next_record();
$res = array();
while($next_rec) {
array_push($res, $this->db->Record);
$next_rec = $this->db->next_record();
}
return $res;
}
?>