Overview

Packages

  • Core
    • Authentication
    • Backend
    • Cache
    • CEC
    • Chain
    • ContentType
    • Database
    • Datatype
    • Debug
    • Exception
    • Frontend
      • Search
      • URI
      • Util
    • GenericDB
      • Model
    • GUI
      • HTML
    • I18N
    • LayoutHandler
    • Log
    • Security
    • Session
    • Util
    • Validation
    • Versioning
    • XML
  • Module
    • ContentSitemapHtml
    • ContentSitemapXml
    • ContentUserForum
    • NavigationTop
  • mpAutoloaderClassMap
  • None
  • Plugin
    • ContentAllocation
    • CronjobOverview
    • FormAssistant
    • FrontendLogic
    • FrontendUsers
    • Linkchecker
    • ModRewrite
    • Newsletter
    • Repository
      • FrontendNavigation
      • KeywordDensity
    • SearchSolr
    • SmartyWrapper
    • UrlShortener
    • UserForum
    • Workflow
  • PluginManager
  • Setup
    • Form
    • GUI
    • Helper
      • Environment
      • Filesystem
      • MySQL
      • PHP
    • UpgradeJob

Classes

  • cDb
  • cDbDriverAbstract
  • cDbDriverHandler
  • cDbDriverMysql
  • cDbDriverMysqli

Exceptions

  • cDbException
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated
  • Todo
  1: <?php
  2: /**
  3:  * This file contains the abstract database driver class.
  4:  *
  5:  * @package Core
  6:  * @subpackage Database
  7:  * @version SVN Revision $Rev:$
  8:  *
  9:  * @author Dominik Ziegler
 10:  * @copyright four for business AG <www.4fb.de>
 11:  * @license http://www.contenido.org/license/LIZENZ.txt
 12:  * @link http://www.4fb.de
 13:  * @link http://www.contenido.org
 14:  */
 15: 
 16: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
 17: 
 18: /**
 19:  * This class contains abstract method definitions for each database driver in
 20:  * CONTENIDO.
 21:  *
 22:  * @package Core
 23:  * @subpackage Database
 24:  */
 25: abstract class cDbDriverAbstract {
 26: 
 27:     /**
 28:      * Local database configuration.
 29:      *
 30:      * @var array
 31:      */
 32:     protected $_dbCfg = array();
 33: 
 34:     /**
 35:      * Driver handler instance.
 36:      *
 37:      * @var cDbDriverHandler
 38:      */
 39:     protected $_handler = NULL;
 40: 
 41:     /**
 42:      * Constructor of the database driver.
 43:      * Currently stores the given configuration locally.
 44:      *
 45:      * @param array $dbCfg database configuration
 46:      */
 47:     public function __construct($dbCfg) {
 48:         $this->_dbCfg = $dbCfg;
 49:     }
 50: 
 51:     /**
 52:      * Sets the database driver handler.
 53:      *
 54:      * @param cDbDriverHandler $handler database driver handler instance
 55:      */
 56:     public function setHandler(cDbDriverHandler $handler) {
 57:         $this->_handler = $handler;
 58:     }
 59: 
 60:     /**
 61:      * Returns the database driver handler instance.
 62:      *
 63:      * @return cDbDriverHandler NULL
 64:      */
 65:     public function getHandler() {
 66:         return $this->_handler;
 67:     }
 68: 
 69:     /**
 70:      * Abstract method for checking database driver base functions.
 71:      * If this check fails, the database connection will not be established.
 72:      *
 73:      * @return bool
 74:      */
 75:     abstract public function check();
 76: 
 77:     /**
 78:      * Connects to the database.
 79:      *
 80:      * @return object resource int NULL value depends on
 81:      *         used driver and is NULL in case of an error.
 82:      */
 83:     abstract public function connect();
 84: 
 85:     /**
 86:      * Builds a insert query.
 87:      * String values in passed fields
 88:      * parameter will be escaped automatically.
 89:      *
 90:      * @param string $tableName The table name
 91:      * @param array $fields Associative array of fields to insert
 92:      *
 93:      * @return string The INSERT SQL query
 94:      */
 95:     abstract public function buildInsert($tableName, array $fields);
 96: 
 97:     /**
 98:      * Builds a update query.
 99:      * String values in passed fields
100:      * and whereClauses parameter will be escaped automatically.
101:      *
102:      * @param string $tableName The table name
103:      * @param array $fields Assoziative array of fields to update
104:      * @param array $whereClauses Assoziative array of field in where clause.
105:      *        Multiple entries will be concatenated with AND
106:      *
107:      * @return string The UPDATE query
108:      */
109:     abstract public function buildUpdate($tableName, array $fields, array $whereClauses);
110: 
111:     /**
112:      * Executes the query.
113:      *
114:      * @param string $statement The query to execute
115:      */
116:     abstract public function query($statement);
117: 
118:     /**
119:      * Moves the result to the next record, if exists and returns the status of
120:      * the movement
121:      *
122:      * @return int Flag about move status 1 on success or 0
123:      */
124:     abstract public function nextRecord();
125: 
126:     /**
127:      * This method returns the current result set as object or NULL if no result
128:      * set is left.
129:      * If optional param $className is set, the result object is an instance of
130:      * class
131:      * $className.
132:      *
133:      * @param string $className
134:      * @return object
135:      */
136:     abstract public function getResultObject($className = NULL);
137: 
138:     /**
139:      * Returns number of affected rows from last executed query (update, delete)
140:      *
141:      * @return int Number of affected rows
142:      */
143:     abstract public function affectedRows();
144: 
145:     /**
146:      * Returns the number of rows from last executed select query.
147:      *
148:      * @return int The number of rows from last select query result
149:      */
150:     abstract public function numRows();
151: 
152:     /**
153:      * Returns the number of fields (columns) from current record set
154:      *
155:      * @return int Number of fields
156:      */
157:     abstract public function numFields();
158: 
159:     /**
160:      * Discard the query result
161:      */
162:     abstract public function free();
163: 
164:     /**
165:      * Escape string for using in SQL-Statement.
166:      *
167:      * @param string $string The string to escape
168:      * @return string Escaped string
169:      */
170:     abstract public function escape($string);
171: 
172:     /**
173:      * Moves the cursor (position inside current result sets).
174:      *
175:      * @param int $iPos The positon to move to inside the current result set
176:      */
177:     abstract public function seek($iPos = 0);
178: 
179:     /**
180:      * Parses te table structure and generates a metadata from it.
181:      *
182:      * Due to compatibility problems with Table we changed the behavior
183:      * of metadata();
184:      * depending on $full, metadata returns the following values:
185:      *
186:      * - full is false (default):
187:      * $result[]:
188:      * [0]["table"] table name
189:      * [0]["name"] field name
190:      * [0]["type"] field type
191:      * [0]["len"] field length
192:      * [0]["flags"] field flags
193:      *
194:      * - full is true
195:      * $result[]:
196:      * ["num_fields"] number of metadata records
197:      * [0]["table"] table name
198:      * [0]["name"] field name
199:      * [0]["type"] field type
200:      * [0]["len"] field length
201:      * [0]["flags"] field flags
202:      * ["meta"][field name] index of field named "field name"
203:      * This last one could be used if you have a field name, but no index.
204:      * Test: if (isset($result['meta']['myfield'])) { ...
205:      *
206:      *
207:      * @param string $tableName The table to get metadata or empty string to
208:      *            retrieve
209:      *        metadata of all tables
210:      * @param bool $full Flag to load full metadata
211:      *
212:      * @return array Depends on used database and on parameter $full
213:      */
214:     abstract public function getMetaData($tableName, $full = false);
215: 
216:     /**
217:      * Fetches all table names.
218:      *
219:      * @return array
220:      */
221:     abstract public function getTableNames();
222: 
223:     /**
224:      * Fetches server information.
225:      *
226:      * @return array
227:      */
228:     abstract public function getServerInfo();
229: 
230:     /**
231:      * Returns error code of last occured error by using databases interface.
232:      *
233:      * @return int
234:      */
235:     abstract public function getErrorNumber();
236: 
237:     /**
238:      * Returns error message of last occured error by using databases interface.
239:      *
240:      * @return string
241:      */
242:     abstract public function getErrorMessage();
243: 
244:     /**
245:      * Closes the connection and frees the query id.
246:      */
247:     abstract public function disconnect();
248: }
CMS CONTENIDO 4.9.3 API documentation generated by ApiGen 2.8.0