[ Index ] |
|
Code source de CMS made simple 1.0.5 |
1 <?php 2 3 function load_adodb() 4 { 5 global $config; 6 7 // @TODO: Remove dependence on PEAR for error handling 8 if ($config['debug'] == true) 9 { 10 #@include_once(cms_join_path(dirname(__FILE__), $config['use_adodb_lite'] == true ? 'adodb_lite' : 'adodb', 'adodb-errorpear.inc.php')); 11 } 12 13 define('ADODB_OUTP', 'debug_sql'); 14 15 $loaded_adodb = false; 16 17 if ($config['use_adodb_lite'] == false || (isset($USE_OLD_ADODB) && $USE_OLD_ADODB == 1)) 18 { 19 # CMSMS is configured to use full ADOdb 20 $full_adodb = cms_join_path(dirname(__FILE__),'adodb','adodb.inc.php'); 21 if (! file_exists($full_adodb)) 22 { 23 # Full ADOdb cannot be found, show a debug error message 24 $gCms->errors[] = 'CMS Made Simple is configured to use the full ADOdb Database Abstraction library, but it\'s not in the lib' .DIRECTORY_SEPARATOR. 'adodb directory. Switched back to ADOdb Lite.'; 25 } 26 else 27 { 28 # Load (full) ADOdb 29 require($full_adodb); 30 $loaded_adodb = true; 31 } 32 } 33 if (!$loaded_adodb) 34 { 35 $adodb_light = cms_join_path(dirname(__FILE__),'adodb_lite','adodb.inc.php'); 36 # The ADOdb library is not yet included, try ADOdb Lite 37 if (file_exists($adodb_light)) 38 { 39 # Load ADOdb Lite 40 require($adodb_light); 41 } 42 else 43 { 44 # ADOdb cannot be found, show a message and stop the script execution 45 die('The ADOdb Lite database abstraction library cannot be found, CMS Made Simple cannot load.'); 46 } 47 } 48 49 define('CMS_ADODB_DT', $config['use_adodb_lite'] ? 'DT' : 'T'); 50 } 51 52 function & adodb_connect() 53 { 54 global $config; 55 56 $dbinstance =& ADONewConnection($config['dbms'], 'pear:date:extend:transaction'); 57 $conn_func = (isset($config['persistent_db_conn']) && $config['persistent_db_conn'] == true) ? 'PConnect' : 'Connect'; 58 $connect_result = $dbinstance->$conn_func($config['db_hostname'], $config['db_username'], $config['db_password'], $config['db_name']); 59 60 if (FALSE == $connect_result) 61 { 62 die('Database Connection failed'); 63 } 64 65 $dbinstance->SetFetchMode(ADODB_FETCH_ASSOC); 66 67 if ($config['debug'] == true) 68 { 69 $dbinstance->debug = true; 70 #$dbinstance->LogSQL(); 71 } 72 73 if ($config['dbms'] == 'sqlite') 74 { 75 $dbinstance->Execute('PRAGMA short_column_names = 1;'); 76 sqlite_create_function($config['use_adodb_lite'] ? $db->connectionId : $db->_connectionID, 'now', 'time', 0); 77 } 78 79 $db =& $dbinstance; 80 return $db; 81 } 82 83 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Tue Apr 3 18:50:37 2007 | par Balluche grâce à PHPXref 0.7 |