l3.cas-d-astre/includes/libuserinfo.inc.php

86 lines
1.9 KiB
PHP
Raw Permalink Normal View History

2009-05-01 08:39:36 +00:00
<?php
if (!defined("LIBUSERINFO_INC")){
define(LIBUSERINFO_INC,1);
define(LIBUSERINFO_CAT_ACHETEUR,'ACH');
define(LIBUSERINFO_CAT_MAGASINIER,'MAG');
define(LIBUSERINFO_CAT_OTHER,'OTH');
class UserInfo {
var $_firstName;
var $_secondName;
var $_address;
var $_accessLevel;
var $_id;
var $_site;
function UserInfo($login, $accesslevel, $category, $catid){
$query="";
if ($category==LIBUSERINFO_CAT_OTHER){
} else {
switch($category){
case LIBUSERINFO_CAT_ACHETEUR:
$query="SELECT * FROM Acheteur WHERE ID_ACHETEUR='$catid' "
."ORDER BY ID_ACHETEUR DESC LIMIT 0,1";
break;
case LIBUSERINFO_CAT_MAGASINIER:
$query="SELECT * FROM Magasinier WHERE ID_MAGASINIER='$catid' "
."ORDER BY ID_MAGASINIER DESC LIMIT 0,1";
break;
default: break; /* TODO: ERREUR */
}
$connexion = @mysql_connect(SQL_SERVER,SQL_USER,SQL_PASSWD);
if (!$connexion){
die("Erreur serveur mysql $connexion");
} else {
$result=mysql_db_query(SQL_BASE,$query)
or die($query.":".mysql_error($connexion));
//,$connexion)
if (mysql_num_rows($result)>0){
$row=mysql_fetch_object($result);
$this->_firstName=$row->nom;
$this->_secondName=$row->prenom;
$this->_address=$row->adresse;
$this->_tel=$row->telephone;
$this->_fax=$row->fax;
$this->_site=$row->id_site;
$this->_accessLevel=$accesslevel;
$this->_id=$catid;
/* TODO: remplir l'objet avec les valeurs de la BD */
} else {
mysql_error($connexion);
}
mysql_close($connexion);
}
}
}
function getFirstName(){
return $this->_firstName;
}
function getSecondName(){
return $this->_secondName;
}
function getID(){
return $this->_id;
}
function getSite(){
return $this->_site;
}
function getAccessLevel(){
return $this->_accessLevel;
}
}
}
?>