Database Class Reference

List of all members.

Public Member Functions

Static Public Member Functions

Public Attributes

Protected Member Functions

Protected Attributes

Static Protected Attributes


Detailed Description

Definition at line 16 of file Database.php.


Constructor & Destructor Documentation

Database::__construct (  )  [protected]

Definition at line 78 of file Database.php.

00078                                    {
00079     $this->connect();
00080 
00081     if (!is_resource($this->resConnection) && !is_object($this->resConnection))
00082       throw new Exception(sprintf('Could not connect to database (%s)', $this->error));
00083   }


Member Function Documentation

Database::begin_transaction (  )  [abstract, protected]

Referenced by beginTransaction().

Database::beginTransaction (  ) 

Begin a transaction.

Definition at line 225 of file Database.php.

00226         {
00227                 $this->begin_transaction();
00228         }

Database::commit_transaction (  )  [abstract, protected]

Referenced by commitTransaction().

Database::commitTransaction (  ) 

Commit a transaction.

Definition at line 234 of file Database.php.

00235         {
00236                 $this->commit_transaction();
00237         }

Database::connect (  )  [abstract, protected]

Abstract database driver methods.

Referenced by __construct().

Database::DBPerform ( table,
data,
action,
parameters 
)

Definition at line 120 of file Database.php.

00120                                                                 {
00121     $strClass = DB_DRIVER . '_Statement';
00122     $objStatement = new $strClass($this->resConnection, $this->blnDisableAutocommit);
00123 
00124     return $objStatement->DBPerform($table, $data, $action, $parameters);
00125   }

Database::disconnect (  )  [abstract, protected]
Database::fieldExists ( strField,
strTable,
blnNoCache = false 
)

Determine if a particular column exists.

Parameters:
string 
string 
boolean 
Returns:
boolean

Definition at line 196 of file Database.php.

00197         {
00198                 foreach ($this->listFields($strTable, $blnNoCache) as $arrField)
00199                 {
00200                         if ($arrField['name'] == $strField)
00201                         {
00202                                 return true;
00203                                 break;
00204                         }
00205                 }
00206 
00207                 return false;
00208         }

Database::get_error (  )  [abstract, protected]
static Database::getInstance (  )  [static]

Definition at line 86 of file Database.php.

Referenced by calculCloud(), item::check(), moneyorder::check(), NewslettersUtility::CheckNewsId(), categorieData::get_count_content_in_category(), categorieData::get_count_products_in_category(), get_db_cache(), productData::get_extra_product(), productData::get_has_product_attributes(), language::get_languages(), get_list_option_dipso(), productData::get_products_attribute_stock(), productData::get_query(), categorieData::get_query(), spu::install(), mzmt::install(), item::install(), flat::install(), moneyorder::install(), price::is_SPPC_grp(), desc_base::load_db_values(), NewslettersUtility::load_modele(), notification::loadConf(), notification::methode(), oscss_navlinks(), item::remove(), moneyorder::remove(), resetInstance(), shoppingCart::restore_contents(), sql_also_purchased_products(), sql_new_products(), sql_upcoming_products(), productData::start(), categorieData::start(), tep_address_format(), tep_currency_exists(), tep_epf_label(), tep_get_address_format_id(), tep_get_countries(), tep_get_extra_fields(), tep_get_manufacturers(), tep_get_zone_code(), tep_get_zone_name(), tep_list_option_value_dipso(), tep_manufacturers_list(), tep_random_select(), tep_update_whos_online(), tep_values_name(), and NewslettersUtility::UpNewsId().

00086                                        {
00087       if(self::$_instance == null) {
00088           $strClass = 'DB_' . ucfirst(strtolower(self::CONNECTOR));
00089           $strFile = sprintf('%s'.DIR_WS_COMMON.'drivers/%s.php', DIR_FS_CATALOG, $strClass);
00090 
00091           if (!file_exists($strFile))  throw new Exception(sprintf('Could not load database driver %s', $strClass));
00092 
00093           include_once($strFile);
00094           define('DB_DRIVER', $strClass);
00095           self::$_instance = new $strClass();
00096       }
00097       return self::$_instance;
00098   }

Database::list_fields ( strTable  )  [abstract, protected]

Referenced by listFields().

Database::listFields ( strTable,
blnNoCache = false 
)

Return all columns of a particular table as array.

Parameters:
string 
boolean 
Returns:
array

Definition at line 177 of file Database.php.

Referenced by fieldExists().

00178         {
00179                 if (!$blnNoCache && isset($this->arrCache[$strTable]))
00180                 {
00181                         return $this->arrCache[$strTable];
00182                 }
00183 
00184                 $this->arrCache[$strTable] = $this->list_fields($strTable);
00185                 return $this->arrCache[$strTable];
00186         }

Database::listTables ( strDatabase = false,
blnNoCache = false 
)

Return all tables of a database as array.

Parameters:
string 
boolean 
Returns:
array

Definition at line 133 of file Database.php.

Referenced by tableExists().

00134   {
00135           if (!$strDatabase)
00136           {
00137                   $strDatabase = $GLOBALS['TL_CONFIG']['dbDatabase'];
00138           }
00139 
00140           if (!$blnNoCache && isset($this->arrCache[$strDatabase]))
00141           {
00142                   return $this->arrCache[$strDatabase];
00143           }
00144 
00145           $arrReturn = array();
00146           $arrTables = $this->execute(sprintf($this->strListTables, $strDatabase))->fetchAllAssoc();
00147 
00148           foreach ($arrTables as $arrTable)
00149           {
00150                   $arrReturn[] = current($arrTable);
00151           }
00152 
00153           $this->arrCache[$strDatabase] = $arrReturn;
00154           return $this->arrCache[$strDatabase];
00155   }

Database::query ( strQuery  ) 

Execute a raw query (return a Database_Result object).

Parameters:
string 
Returns:
object

Definition at line 113 of file Database.php.

00113                                    {
00114     $strClass = DB_DRIVER . '_Statement';
00115     $objStatement = new $strClass($this->resConnection, $this->blnDisableAutocommit);
00116 
00117     return $objStatement->query($strQuery);
00118   }

static Database::resetInstance (  )  [static]

Definition at line 102 of file Database.php.

00102                                          {
00103       self::$_instance = null;
00104       return self::getInstance();
00105   }

Database::rollback_transaction (  )  [abstract, protected]

Referenced by rollbackTransaction().

Database::rollbackTransaction (  ) 

Rollback a transaction.

Definition at line 243 of file Database.php.

00244         {
00245                 $this->rollback_transaction();
00246         }

Database::set_database ( strDatabase  )  [abstract, protected]

Referenced by setDatabase().

Database::setDatabase ( strDatabase  ) 

Change the current database.

Parameters:
string 
Returns:
boolean

Definition at line 216 of file Database.php.

00217         {
00218                 return $this->set_database($strDatabase);
00219         }

Database::tableExists ( strTable,
strDatabase = false,
blnNoCache = false 
)

Determine if a particular database table exists.

Parameters:
string 
string 
boolean 
Returns:
boolean

Definition at line 165 of file Database.php.

00166         {
00167                 return in_array($strTable, $this->listTables($strDatabase, $blnNoCache));
00168         }


Member Data Documentation

Database::$_instance [static, protected]

Definition at line 74 of file Database.php.

Database::$arrCache = array() [protected]

Definition at line 71 of file Database.php.

Database::$blnDisableAutocommit = false [protected]

Definition at line 65 of file Database.php.

Database::$objInstance [static, protected]

Definition at line 53 of file Database.php.

Database::$resConnection [protected]

Definition at line 59 of file Database.php.

Definition at line 42 of file Database.php.

Definition at line 38 of file Database.php.

Definition at line 31 of file Database.php.

Definition at line 21 of file Database.php.

Definition at line 36 of file Database.php.

Definition at line 44 of file Database.php.

Definition at line 40 of file Database.php.

Definition at line 26 of file Database.php.


The documentation for this class was generated from the following file: