Mini Shell
<?php
require_once '_framework/Model.php';
class Fonction extends Model {
public function getFonctions() {
$sql = 'select (select count(id) from prestataires where fonct_id=fonctions.id) as count_prest,* from fonctions order by fonction';
$fonction = $this->runQuery($sql);
return $fonction->fetchAll();
}
public function getFonction($id) {
$sql = 'select * from fonctions'
. ' where id=?';
$fonction = $this->runQuery($sql, array($id));
$rs = $fonction->fetchAll();
if ($rs && count($rs)) {
return $rs;
}
else
throw new ErrorException("Aucune fonction ne correspond à l'identifiant '$id'",0,E_USER_NOTICE);
}
public function addFonction($values) {
$sql = 'insert into fonctions (fonction,attrib1,attrib1_values,attrib1_multi,
attrib2,attrib2_values,attrib2_multi,attrib3,attrib3_values,attrib3_multi)'
. ' values (?,?,?,?,?,?,?,?,?,?)';
$fonction = $this->runQuery($sql, $values);
}
public function deleteFonction($id) {
$sql = 'delete from fonctions'
. ' where id=?';
$fonction = $this->runQuery($sql, array($id));
}
public function updateFonction($values) {
$sql = 'update fonctions set fonction=?,attrib1=?,attrib1_values=?,attrib1_multi=?,
attrib2=?,attrib2_values=?,attrib2_multi=?,attrib3=?,attrib3_values=?,attrib3_multi=?'
. ' where id=?';
$fonction = $this->runQuery($sql, $values);
}
}