Código PHP:
  
0<?php
1 class DbConnector extends SystemComponent {
2 
3     var $theQuery;
4     var $link;
5
6     //*** Function: DbConnector, Purpose: Connect to the database ***
7     function DbConnector(){
8
9         // Load settings from parent class
10         $settings = SystemComponent::getSettings();
11 
12         // Get the main settings from the array we just loaded
13         $host = $settings['dbhost'];
14         $db = $settings['dbname'];
15         $user = $settings['dbusername'];
16         $pass = $settings['dbpassword'];
17 
18         // Connect to the database
19         $this->link = mysql_connect($host, $user, $pass);
20         mysql_select_db($db);
21         register_shutdown_function(array(&$this, 'close'));
22 
23     }
24 
25     //*** Function: query, Purpose: Execute a database query ***
26     function query($query) {
27 
28         $this->theQuery = $query;
29         return mysql_query($query, $this->link);
30 
31     }
32
33     //*** Function: fetchArray, Purpose: Get array of query results ***
34     function fetchArray($result) {
35 
36         return mysql_fetch_array($result);
37 
38     }
39 
40     //*** Function: close, Purpose: Close the connection ***
41     function close() {
42
43        mysql_close($this->link);
44
45    }
46
47 }
48?>    muchas gracias
 
