49,14 → 49,14 |
* @return bool |
*/ |
public function existe($id_element_lie, $cle) { |
$id = $this->proteger($id_element_lie); |
$cle = $this->proteger($cle); |
$id = Cel::db()->proteger($id_element_lie); |
$cle = Cel::db()->proteger($cle); |
$requete = 'SELECT COUNT(*) >= 1 AS existe '. |
"FROM {$this->table_champs_etendus} ". |
"WHERE {$this->champ_id} = $id ". |
" AND cle = $cle "; |
|
$resultat = $this->executerRequete($requete); |
$resultat = Cel::db()->executerRequete($requete); |
return ($resultat[0]['existe'] == '1'); |
} |
|
67,9 → 67,9 |
* @return array tableau associatif des champs de la table etendu |
*/ |
public function consulter($id_element_lie) { |
$id = $this->proteger($id_element_lie); |
$id = Cel::db()->proteger($id_element_lie); |
$requete = "SELECT * FROM {$this->table_champs_etendus} WHERE {$this->champ_id} = $id "; |
$resultat = $this->executerRequete($requete); |
$resultat = Cel::db()->executerRequete($requete); |
return $resultat; |
} |
|
84,11 → 84,11 |
public function consulterParLots(Array $ids_element_lies) { |
$champs_etendus_par_element = array(); |
if (!empty($ids_element_lies)) { |
$ids_element_lies = array_map(array($this, 'proteger'),$ids_element_lies); |
$ids_element_lies = array_map(array(Cel::db(), 'proteger'),$ids_element_lies); |
$ids = implode(',', $ids_element_lies); |
|
$requete = "SELECT * FROM {$this->table_champs_etendus} WHERE {$this->champ_id} IN ($ids) "; |
$resultats = $this->executerRequete($requete); |
$resultats = Cel::db()->executerRequete($requete); |
|
foreach ($resultats as &$ligne) { |
$id_element = $ligne[$this->champ_id]; |
115,10 → 115,10 |
* @return bool true si l'ajout a eu lieu |
*/ |
public function ajouter(ChampEtendu $champ_etendu) { |
$id = $this->proteger($champ_etendu->id); |
$cle = $this->proteger($champ_etendu->cle); |
$label = $this->proteger($champ_etendu->label); |
$valeur = $this->proteger($champ_etendu->valeur); |
$id = Cel::db()->proteger($champ_etendu->id); |
$cle = Cel::db()->proteger($champ_etendu->cle); |
$label = Cel::db()->proteger($champ_etendu->label); |
$valeur = Cel::db()->proteger($champ_etendu->valeur); |
|
$requete = "INSERT INTO {$this->table_champs_etendus} ". |
"( {$this->champ_id}, cle, label, valeur) ". |
127,7 → 127,7 |
|
// la partie on duplicate key est spécifique mysql mais il sera facile de s'en passer le jour |
// où l'on change de sgbd |
$ajout = $this->executerRequeteSimple($requete); |
$ajout = Cel::db()->executerRequeteSimple($requete); |
return ($ajout !== false); |
} |
|
141,10 → 141,10 |
public function ajouterParLots(Array $champs_etendus) { |
$lignes = array(); |
foreach ($champs_etendus as $champ_etendu) { |
$id = $this->proteger($champ_etendu->id); |
$cle = $this->proteger($champ_etendu->cle); |
$label = $this->proteger($champ_etendu->label); |
$valeur = $this->proteger($champ_etendu->valeur); |
$id = Cel::db()->proteger($champ_etendu->id); |
$cle = Cel::db()->proteger($champ_etendu->cle); |
$label = Cel::db()->proteger($champ_etendu->label); |
$valeur = Cel::db()->proteger($champ_etendu->valeur); |
|
$lignes[] = "($id, $cle, $label, $valeur)"; |
} |
157,7 → 157,7 |
|
// la partie on duplicate key est spécifique mysql mais il sera facile de s'en passer le jour |
// où l'on change de sgbd |
$ajout = $this->executerRequeteSimple($requete); |
$ajout = Cel::db()->executerRequeteSimple($requete); |
return ($ajout !== false); |
} |
|
168,10 → 168,10 |
* @return bool true si la modification a eu lieu |
*/ |
public function modifier(ChampEtendu $champ_etendu) { |
$id = $this->proteger($champ_etendu->id); |
$cle = $this->proteger($champ_etendu->cle); |
$label = $this->proteger($champ_etendu->label); |
$valeur = $this->proteger($champ_etendu->valeur); |
$id = Cel::db()->proteger($champ_etendu->id); |
$cle = Cel::db()->proteger($champ_etendu->cle); |
$label = Cel::db()->proteger($champ_etendu->label); |
$valeur = Cel::db()->proteger($champ_etendu->valeur); |
|
$requete = "UPDATE {$this->table_champs_etendus} ". |
"SET label = $label, valeur = $valeur ". |
178,7 → 178,7 |
"WHERE cle = $cle". |
" AND {$this->champ_id} = $id "; |
|
$modif = $this->executerRequeteSimple($requete); |
$modif = Cel::db()->executerRequeteSimple($requete); |
return ($modif !== false); |
} |
|
190,10 → 190,10 |
* @return bool |
*/ |
public function supprimer($id_element_lie, $cle) { |
$id = $this->proteger($id_element_lie); |
$cle = $this->proteger($cle); |
$id = Cel::db()->proteger($id_element_lie); |
$cle = Cel::db()->proteger($cle); |
$requete = "DELETE FROM {$this->table_champs_etendus} WHERE cle = $cle AND {$this->champ_id} = $id "; |
$suppr = $this->executerRequeteSimple($requete); |
$suppr = Cel::db()->executerRequeteSimple($requete); |
return ($suppr !== false); |
} |
|
204,9 → 204,9 |
* @return bool |
*/ |
public function vider($id_element_lie) { |
$id = $this->proteger($id_element_lie); |
$id = Cel::db()->proteger($id_element_lie); |
$requete = "DELETE FROM {$this->table_champs_etendus} WHERE {$this->champ_id} = $id "; |
$suppr = $this->executerRequeteSimple($requete); |
$suppr = Cel::db()->executerRequeteSimple($requete); |
return ($suppr !== false); |
} |
|
219,7 → 219,7 |
public function viderParLots($ids_elements_lies) { |
$ids = $this->protegerTableau($ids_elements_lies); |
$requete = "DELETE FROM {$this->table_champs_etendus} WHERE {$this->champ_id} IN (".implode(',',$ids).") "; |
$suppr = $this->executerRequeteSimple($requete); |
$suppr = Cel::db()->executerRequeteSimple($requete); |
return ($suppr !== false); |
} |
|
234,7 → 234,7 |
if(!empty($ids_elements_lies)) { |
$ids = $this->protegerTableau($ids_elements_lies); |
$requete = "SELECT cle FROM {$this->table_champs_etendus} WHERE {$this->champ_id} IN (".implode(',',$ids).") "; |
$cles = $this->executerRequete($requete); |
$cles = Cel::db()->executerRequete($requete); |
$i = 0; |
foreach($cles as &$cle) { |
$cles_fmt[$cle['cle']] = $i++; |