~sylar-developers/sylar/dev

« back to all changes in this revision

Viewing changes to sylar/classes/common/db/mysql/MysqlDriver.php

  • Committer: g.giusti at giano-solutions
  • Date: 2008-06-03 16:46:51 UTC
  • Revision ID: g.giusti@giano-solutions.com-20080603164651-7mvk9ofws27cmuhx
Some bugs fixed

Show diffs side-by-side

added added

removed removed

Lines of Context:
74
74
                        try{
75
75
                                $this->setConnectionInfo(Sylar_DataBaseManager::getDefaultDbConfiguration());
76
76
                        }catch (ExceptionInSylar $ex){
77
 
                                throw new ExceptionInSylar("Wrong Db Configuration. Check the application configuration file.", 1 );
 
77
                                throw $ex;
78
78
                        }
79
79
                }else{
80
80
                        $this->setConnectionInfo($dbConfiguration);
110
110
        public function setConnectionInfo(Sylar_DataBaseConfiguration $dbConf){
111
111
                
112
112
                if( !$dbConf->checkConfiguration() ){
113
 
                        throw new ExceptionInSylar("Wrong Db Configuration. Check the application configuration file.", 1 );
 
113
                        throw new ExceptionInSylar("Wrong Db Configuration. Check the application configuration file.", 10026 );
114
114
                        return false;
115
115
                }
116
116
                
157
157
                        }
158
158
                        
159
159
                        return $this->db["connection"];
160
 
                        
161
 
                        //$this->db["connection"] = @mysql_connect($this->db["host"], $this->db["user"], $this->db["password"]);
162
 
                        //if ($this->db["connection"]){
163
 
                        //      return $this->db["connection"]; 
164
 
                        //}else{
165
 
                        //      //throw new ExceptionInSylar("MySQL Err.no: ".mysql_errno()." MySQL Err.: ".mysql_error()."\n".__METHOD__." Line: ".__LINE__ );
166
 
                        //      throw new ExceptionInSylar("Impossibile connettersi",0);
167
 
                        //}
 
160
                
168
161
                }catch (ExceptionInSylar $ex){
169
162
                        throw $ex;
170
163
                        return null;
184
177
        public function disconnect(){
185
178
                if($this->isConnected()){
186
179
                        if(!@mysql_close($this->db["connection"])){
187
 
                                throw new ExceptionInSylar("MySQL Err.no: ".mysql_errno()." MySQL Err.: ".mysql_error()."\n".__METHOD__." Line: ".__LINE__ );
 
180
                                throw new ExceptionInSylar("MySQL Err.no: ".mysql_errno()." MySQL Err.: ".mysql_error()."\n".__METHOD__." Line: ".__LINE__, 10027 );
188
181
                                return false;
189
182
                        }
190
183
                }
213
206
                        
214
207
                        $this->db["results"] = @mysql_db_query($this->db["db"], $query, $this->db["connection"]);
215
208
                        if (!$this->db["results"]) {
216
 
                                throw new ExceptionInSylar('Error in MySQL execQuery. Errno: '.mysql_errno()." Err: ".mysql_error() );
 
209
                                throw new ExceptionInSylar('Error in MySQL execQuery. Errno: '.mysql_errno()." Err: ".mysql_error(), 10028 );
217
210
                                return false;
218
211
                        }else{
219
212
                                return $this->db["results"];
251
244
                        
252
245
                        $this->db["results"] = $this->execQuery($query);
253
246
                        if (!$this->db["results"]) {
254
 
                        throw new ExceptionInSylar("MySQL Err.no: ".mysql_errno()." MySQL Err.: ".mysql_error()."\n".__METHOD__." Line: ".__LINE__ );
 
247
                        throw new ExceptionInSylar("MySQL Err.no: ".mysql_errno()." MySQL Err.: ".mysql_error()."\n".__METHOD__." Line: ".__LINE__, 10028 );
255
248
                    }               
256
249
                        $this->disconnect();
257
250
                        
289
282
                if($this->isConnected()){
290
283
                        return @mysql_insert_id($this->db["connection"]);
291
284
                }else{
292
 
                        throw new ExceptionInSylar("MySQL Err.no: ".mysql_errno()." MySQL Err.: ".mysql_error()."\n".__METHOD__." Line: ".__LINE__ );
 
285
                        throw new ExceptionInSylar("MySQL Err.no: ".mysql_errno()." MySQL Err.: ".mysql_error()."\n".__METHOD__." Line: ".__LINE__, 10029 );
293
286
                        return false;
294
287
                }
295
288
        }
310
303
                if($this->isConnected()){
311
304
                        return @mysql_affected_rows($this->db["connection"]);
312
305
                }else{
313
 
                        throw new ExceptionInSylar("MySQL Err.no: ".mysql_errno()." MySQL Err.: ".mysql_error()."\n".__METHOD__." Line: ".__LINE__ );
 
306
                        throw new ExceptionInSylar("MySQL Err.no: ".mysql_errno()." MySQL Err.: ".mysql_error()."\n".__METHOD__." Line: ".__LINE__, 10030 );
314
307
                        return false;
315
308
                }
316
309
        }