

Public Member Functions | |
| db_connect () | |
| Non-persistent database connection. | |
| db_pconnect () | |
| Persistent database connection. | |
| db_select () | |
| Select the database. | |
| db_set_charset ($charset, $collation) | |
| Set client character set. | |
| _execute ($sql) | |
| Execute the query. | |
| _prep_query ($sql) | |
| Prep the query. | |
| trans_begin ($test_mode=FALSE) | |
| Begin Transaction. | |
| trans_commit () | |
| Commit Transaction. | |
| trans_rollback () | |
| Rollback Transaction. | |
| escape_str ($str) | |
| Escape String. | |
| affected_rows () | |
| Affected Rows. | |
| insert_id () | |
| Insert ID. | |
| _parse_major_version ($version) | |
| Parse major version. | |
| _version () | |
| Version number query string. | |
| count_all ($table= '') | |
| "Count All" query | |
| _list_tables ($prefix_limit=FALSE) | |
| List table query. | |
| _list_columns ($table= '') | |
| List column query. | |
| _field_data ($table) | |
| Field data query. | |
| _error_message () | |
| The error message string. | |
| _error_number () | |
| The error message number. | |
| _escape_identifiers ($item) | |
| Escape the SQL Identifiers. | |
| _from_tables ($tables) | |
| From Tables. | |
| _insert ($table, $keys, $values) | |
| Insert statement. | |
| _update ($table, $values, $where, $orderby=array(), $limit=FALSE) | |
| Update statement. | |
| _truncate ($table) | |
| Truncate statement. | |
| _delete ($table, $where=array(), $like=array(), $limit=FALSE) | |
| Delete statement. | |
| _limit ($sql, $limit, $offset) | |
| Limit string. | |
| _close ($conn_id) | |
| Close DB Connection. | |
Public Attributes | |
| $dbdriver = 'mssql' | |
| $_escape_char = '' | |
| $_count_string = "SELECT COUNT(*) AS " | |
| The syntax to count rows is slightly different across different database engines, so this string appears in each driver and is used for the count_all() and count_all_results() functions. | |
| $_random_keyword = ' ASC' | |
Definition at line 31 of file mssql_driver.php.
| CI_DB_mssql_driver::_close | ( | $ | conn_id | ) |
Close DB Connection.
public
| resource |
Definition at line 601 of file mssql_driver.php.
| CI_DB_mssql_driver::_delete | ( | $ | table, | |
| $ | where = array(), |
|||
| $ | like = array(), |
|||
| $ | limit = FALSE | |||
| ) |
Delete statement.
Generates a platform-specific delete string from the supplied data
public
| string | the table name | |
| array | the where clause | |
| string | the limit clause |
Definition at line 551 of file mssql_driver.php.
00552 { 00553 $conditions = ''; 00554 00555 if (count($where) > 0 OR count($like) > 0) 00556 { 00557 $conditions = "\nWHERE "; 00558 $conditions .= implode("\n", $this->ar_where); 00559 00560 if (count($where) > 0 && count($like) > 0) 00561 { 00562 $conditions .= " AND "; 00563 } 00564 $conditions .= implode("\n", $like); 00565 } 00566 00567 $limit = ( ! $limit) ? '' : ' LIMIT '.$limit; 00568 00569 return "DELETE FROM ".$table.$conditions.$limit; 00570 }
| CI_DB_mssql_driver::_error_message | ( | ) |
| CI_DB_mssql_driver::_error_number | ( | ) |
| CI_DB_mssql_driver::_escape_identifiers | ( | $ | item | ) |
Escape the SQL Identifiers.
This function escapes column and table names
private
| string |
Definition at line 424 of file mssql_driver.php.
00425 { 00426 if ($this->_escape_char == '') 00427 { 00428 return $item; 00429 } 00430 00431 if (strpos($item, '.') !== FALSE) 00432 { 00433 $str = $this->_escape_char.str_replace('.', $this->_escape_char.'.'.$this->_escape_char, $item).$this->_escape_char; 00434 } 00435 else 00436 { 00437 $str = $this->_escape_char.$item.$this->_escape_char; 00438 } 00439 00440 // remove duplicates if the user already included the escape 00441 return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str); 00442 }
| CI_DB_mssql_driver::_execute | ( | $ | sql | ) |
Execute the query.
private called by the base class
| string | an SQL query |
Definition at line 119 of file mssql_driver.php.
References _prep_query().
00120 { 00121 $sql = $this->_prep_query($sql); 00122 return @mssql_query($sql, $this->conn_id); 00123 }

| CI_DB_mssql_driver::_field_data | ( | $ | table | ) |
Field data query.
Generates a platform-specific query so that the column data can be retrieved
public
| string | the table name |
Definition at line 380 of file mssql_driver.php.
| CI_DB_mssql_driver::_from_tables | ( | $ | tables | ) |
From Tables.
This function implicitly groups FROM tables so there is no confusion about operator precedence in harmony with SQL standards
public
| type |
Definition at line 456 of file mssql_driver.php.
00457 { 00458 if ( ! is_array($tables)) 00459 { 00460 $tables = array($tables); 00461 } 00462 00463 return implode(', ', $tables); 00464 }
| CI_DB_mssql_driver::_insert | ( | $ | table, | |
| $ | keys, | |||
| $ | values | |||
| ) |
Insert statement.
Generates a platform-specific insert string from the supplied data
public
| string | the table name | |
| array | the insert keys | |
| array | the insert values |
Definition at line 479 of file mssql_driver.php.
00480 { 00481 return "INSERT INTO ".$table." (".implode(', ', $keys).") VALUES (".implode(', ', $values).")"; 00482 }
| CI_DB_mssql_driver::_limit | ( | $ | sql, | |
| $ | limit, | |||
| $ | offset | |||
| ) |
Limit string.
Generates a platform-specific LIMIT clause
public
| string | the sql query string | |
| integer | the number of rows to limit the query to | |
| integer | the offset value |
Definition at line 585 of file mssql_driver.php.
00586 { 00587 $i = $limit + $offset; 00588 00589 return preg_replace('/(^\SELECT (DISTINCT)?)/i','\\1 TOP '.$i.' ', $sql); 00590 }
| CI_DB_mssql_driver::_list_columns | ( | $ | table = '' |
) |
List column query.
Generates a platform-specific query string so that the column names can be fetched
private
| string | the table name |
Definition at line 364 of file mssql_driver.php.
00365 { 00366 return "SELECT * FROM INFORMATION_SCHEMA.Columns WHERE TABLE_NAME = '".$table."'"; 00367 }
| CI_DB_mssql_driver::_list_tables | ( | $ | prefix_limit = FALSE |
) |
List table query.
Generates a platform-specific query string so that the table names can be fetched
private
| boolean |
Definition at line 339 of file mssql_driver.php.
00340 { 00341 $sql = "SELECT name FROM sysobjects WHERE type = 'U' ORDER BY name"; 00342 00343 // for future compatibility 00344 if ($prefix_limit !== FALSE AND $this->dbprefix != '') 00345 { 00346 //$sql .= " LIKE '".$this->dbprefix."%'"; 00347 return FALSE; // not currently supported 00348 } 00349 00350 return $sql; 00351 }
| CI_DB_mssql_driver::_parse_major_version | ( | $ | version | ) |
Parse major version.
Grabs the major version number from the database server version string passed in.
private
| string | $version |
Definition at line 283 of file mssql_driver.php.
Referenced by insert_id().
00284 { 00285 preg_match('/([0-9]+)\.([0-9]+)\.([0-9]+)/', $version, $ver_info); 00286 return $ver_info[1]; // return the major version b/c that's all we're interested in. 00287 }

| CI_DB_mssql_driver::_prep_query | ( | $ | sql | ) |
Prep the query.
If needed, each database adapter can prep the query string
private called by execute()
| string | an SQL query |
Definition at line 136 of file mssql_driver.php.
Referenced by _execute().

| CI_DB_mssql_driver::_truncate | ( | $ | table | ) |
Truncate statement.
Generates a platform-specific truncate string from the supplied data If the database does not support the truncate() command This function maps to "DELETE FROM table"
public
| string | the table name |
Definition at line 533 of file mssql_driver.php.
| CI_DB_mssql_driver::_update | ( | $ | table, | |
| $ | values, | |||
| $ | where, | |||
| $ | orderby = array(), |
|||
| $ | limit = FALSE | |||
| ) |
Update statement.
Generates a platform-specific update string from the supplied data
public
| string | the table name | |
| array | the update data | |
| array | the where clause | |
| array | the orderby clause | |
| array | the limit clause |
Definition at line 499 of file mssql_driver.php.
00500 { 00501 foreach($values as $key => $val) 00502 { 00503 $valstr[] = $key." = ".$val; 00504 } 00505 00506 $limit = ( ! $limit) ? '' : ' LIMIT '.$limit; 00507 00508 $orderby = (count($orderby) >= 1)?' ORDER BY '.implode(", ", $orderby):''; 00509 00510 $sql = "UPDATE ".$table." SET ".implode(', ', $valstr); 00511 00512 $sql .= ($where != '' AND count($where) >=1) ? " WHERE ".implode(" ", $where) : ''; 00513 00514 $sql .= $orderby.$limit; 00515 00516 return $sql; 00517 }
| CI_DB_mssql_driver::_version | ( | ) |
| CI_DB_mssql_driver::affected_rows | ( | ) |
| CI_DB_mssql_driver::count_all | ( | $ | table = '' |
) |
"Count All" query
Generates a platform-specific query string that counts all records in the specified database
public
| string |
Definition at line 314 of file mssql_driver.php.
00315 { 00316 if ($table == '') 00317 return '0'; 00318 00319 $query = $this->query($this->_count_string . $this->_protect_identifiers('numrows'). " FROM " . $this->_protect_identifiers($table, TRUE, NULL, FALSE)); 00320 00321 if ($query->num_rows() == 0) 00322 return '0'; 00323 00324 $row = $query->row(); 00325 return $row->numrows; 00326 }
| CI_DB_mssql_driver::db_connect | ( | ) |
Non-persistent database connection.
private called by the base class
Definition at line 51 of file mssql_driver.php.
00052 { 00053 if ($this->port != '') 00054 { 00055 $this->hostname .= ','.$this->port; 00056 } 00057 00058 return @mssql_connect($this->hostname, $this->username, $this->password); 00059 }
| CI_DB_mssql_driver::db_pconnect | ( | ) |
Persistent database connection.
private called by the base class
Definition at line 69 of file mssql_driver.php.
00070 { 00071 if ($this->port != '') 00072 { 00073 $this->hostname .= ','.$this->port; 00074 } 00075 00076 return @mssql_pconnect($this->hostname, $this->username, $this->password); 00077 }
| CI_DB_mssql_driver::db_select | ( | ) |
Select the database.
private called by the base class
Definition at line 87 of file mssql_driver.php.
00088 { 00089 // Note: The brackets are required in the event that the DB name 00090 // contains reserved characters 00091 return @mssql_select_db('['.$this->database.']', $this->conn_id); 00092 }
| CI_DB_mssql_driver::db_set_charset | ( | $ | charset, | |
| $ | collation | |||
| ) |
Set client character set.
public
| string | ||
| string |
Definition at line 104 of file mssql_driver.php.
| CI_DB_mssql_driver::escape_str | ( | $ | str | ) |
Escape String.
public
| string |
Definition at line 230 of file mssql_driver.php.
References $CI, and get_instance().
00231 { 00232 // Access the CI object 00233 $CI =& get_instance(); 00234 00235 // Escape single quotes 00236 return str_replace("'", "''", $CI->input->_remove_invisible_characters($str)); 00237 }

| CI_DB_mssql_driver::insert_id | ( | ) |
Insert ID.
Returns the last id created in the Identity column.
public
Definition at line 262 of file mssql_driver.php.
References _parse_major_version().
00263 { 00264 $ver = self::_parse_major_version($this->version()); 00265 $sql = ($ver >= 8 ? "SELECT SCOPE_IDENTITY() AS last_id" : "SELECT @@IDENTITY AS last_id"); 00266 $query = $this->query($sql); 00267 $row = $query->row(); 00268 return $row->last_id; 00269 }

| CI_DB_mssql_driver::trans_begin | ( | $ | test_mode = FALSE |
) |
Begin Transaction.
public
Definition at line 149 of file mssql_driver.php.
00150 { 00151 if ( ! $this->trans_enabled) 00152 { 00153 return TRUE; 00154 } 00155 00156 // When transactions are nested we only begin/commit/rollback the outermost ones 00157 if ($this->_trans_depth > 0) 00158 { 00159 return TRUE; 00160 } 00161 00162 // Reset the transaction failure flag. 00163 // If the $test_mode flag is set to TRUE transactions will be rolled back 00164 // even if the queries produce a successful result. 00165 $this->_trans_failure = ($test_mode === TRUE) ? TRUE : FALSE; 00166 00167 $this->simple_query('BEGIN TRAN'); 00168 return TRUE; 00169 }
| CI_DB_mssql_driver::trans_commit | ( | ) |
Commit Transaction.
public
Definition at line 179 of file mssql_driver.php.
00180 { 00181 if ( ! $this->trans_enabled) 00182 { 00183 return TRUE; 00184 } 00185 00186 // When transactions are nested we only begin/commit/rollback the outermost ones 00187 if ($this->_trans_depth > 0) 00188 { 00189 return TRUE; 00190 } 00191 00192 $this->simple_query('COMMIT TRAN'); 00193 return TRUE; 00194 }
| CI_DB_mssql_driver::trans_rollback | ( | ) |
Rollback Transaction.
public
Definition at line 204 of file mssql_driver.php.
00205 { 00206 if ( ! $this->trans_enabled) 00207 { 00208 return TRUE; 00209 } 00210 00211 // When transactions are nested we only begin/commit/rollback the outermost ones 00212 if ($this->_trans_depth > 0) 00213 { 00214 return TRUE; 00215 } 00216 00217 $this->simple_query('ROLLBACK TRAN'); 00218 return TRUE; 00219 }
| CI_DB_mssql_driver::$_count_string = "SELECT COUNT(*) AS " |
The syntax to count rows is slightly different across different database engines, so this string appears in each driver and is used for the count_all() and count_all_results() functions.
Definition at line 42 of file mssql_driver.php.
| CI_DB_mssql_driver::$_escape_char = '' |
Definition at line 36 of file mssql_driver.php.
| CI_DB_mssql_driver::$_random_keyword = ' ASC' |
Definition at line 43 of file mssql_driver.php.
| CI_DB_mssql_driver::$dbdriver = 'mssql' |
Definition at line 33 of file mssql_driver.php.