25 private $_sClassSgbd=null;
27 private static $_tInstance=array();
29 protected $_tAssoc=array();
31 public function getConfig(){
32 return $this->sConfig;
34 public function getTable(){
44 if($this->_sClassSgbd==null){
48 $sMsg=
'Il vous manque un fichier de configuration';
49 $sMsg.=
' ou le bloc de configuration ['.$sVarIniConfig.
'] concernant la connexion'.
"\n";
53 mysql.dsn="mysql:dbname=blog;host=localhost"
55 mysql.hostname=localhost
60 throw new Exception($sMsg);
62 $this->_sClassSgbd=
'sgbd_'.$tClassSgbd[$this->sConfig.
'.sgbd'];
64 if(substr($this->_sClassSgbd,0,8)==
'sgbd_pdo'){
66 }elseif(substr($this->_sClassSgbd,0,5)==
'sgbd_'){
69 if(!file_exists($sClassPath)){
71 $tListPdo=$oDirPdo->getListFile();
72 $tPlus=array(
'Liste driver pdo:');
73 foreach($tListPdo as $oFile){
74 $tPlus[]=
'-'.$oFile->getName();
77 $sListePdo=implode(
"\n",$tPlus);
80 $tList=$oDir->getListFile();
81 $tPlus=array(
'Liste driver autre:');
82 foreach($tList as $oFile){
83 $tPlus[]=
'-'.$oFile->getName();
85 $sListeAutre=implode(
"\n",$tPlus);
87 throw new Exception(
'Pas de driver '.$this->_sClassSgbd.
' ('.$sClassPath.
')'.
"\n".$sListePdo.
"\n".$sListeAutre);
91 $this->_oSgbd=call_user_func( array($this->_sClassSgbd,
'getInstance'),$this->sConfig);
94 $this->_oSgbd->setConfig($tClassSgbd);
107 $tSql=func_get_args();
108 $oObj= $this->
getSgbd()->findOneSimple($tSql,$this->sClassRow);
120 $tSql=func_get_args();
121 $oObj= $this->
getSgbd()->findOne($tSql,$this->sClassRow);
133 $tSql=func_get_args();
134 $tObj= $this->
getSgbd()->findMany($tSql,$this->sClassRow);
146 $tSql=func_get_args();
147 $tObj= $this->
getSgbd()->findManySimple($tSql,$this->sClassRow);
158 $tSql=func_get_args();
159 $handle=$this->
getSgbd()->execute($tSql);
169 $this->
getSgbd()->update($this->sTable,$oRow->getToUpdate(),$oRow->getWhere());
178 $oInsert= $this->
getSgbd()->insert($this->sTable,$oRow->getToUpdate());
187 public function delete($oRow){
188 $this->
getSgbd()->delete($this->sTable,$oRow->getWhere());
197 return $this->
getSgbd()->getRequete();
199 public function getIdTab(){
208 return $this->
getSgbd()->getListColumn($this->sTable);
216 return $this->
getSgbd()->getListTable();
219 public function getWhereFromTab($tWhere=null){
227 if(is_array($tWhere)){
228 foreach($tWhere as $sVar => $sVal){
229 $sWhere.=$sVar.
'='.$this->quote($sVal).
' AND';
231 return substr($sWhere,0,-3);
233 return $this->tId[0].
'='.$tWhere;
237 protected static function _getInstance($class) {
238 if (array_key_exists($class, self::$_tInstance) ===
false){
239 self::$_tInstance[$class] =
new $class();
241 return self::$_tInstance[$class];
static getConfigVar($sCatAndVar, $uDefaut=null)