From d09c51afac9df77a52380dc2ac6581a104faa2ff Mon Sep 17 00:00:00 2001
From: "anaxamaxan@blackdog.local"
Date: Wed, 2 Feb 2011 23:00:16 -0800
Subject: Made config->base_url() accept parameters. config->base_url($uri).
Updated base_url() in url_helper accordingly.
---
system/core/Config.php | 58 ++++++++++++++++++++++++++++++++++---------
system/helpers/url_helper.php | 11 +++++---
2 files changed, 53 insertions(+), 16 deletions(-)
diff --git a/system/core/Config.php b/system/core/Config.php
index da22222dc..554b7360a 100644
--- a/system/core/Config.php
+++ b/system/core/Config.php
@@ -194,10 +194,7 @@ class CI_Config {
// --------------------------------------------------------------------
/**
- * Fetch a config file item - adds slash after item
- *
- * The second parameter allows a slash to be added to the end of
- * the item, in the case of a path.
+ * Fetch a config file item - adds slash after item (if item is not empty)
*
* @access public
* @param string the config item name
@@ -210,6 +207,10 @@ class CI_Config {
{
return FALSE;
}
+ if( trim($this->config[$item]) == '')
+ {
+ return '';
+ }
return rtrim($this->config[$item], '/').'/';
}
@@ -218,6 +219,7 @@ class CI_Config {
/**
* Site URL
+ * Returns base_url . index_page [. uri_string]
*
* @access public
* @param string the URI string
@@ -230,16 +232,50 @@ class CI_Config {
return $this->slash_item('base_url').$this->item('index_page');
}
+ if ($this->item('enable_query_strings') == FALSE)
+ {
+ $suffix = ($this->item('url_suffix') == FALSE) ? '' : $this->item('url_suffix');
+ return $this->slash_item('base_url').$this->slash_item('index_page').$this->_uri_string($uri).$suffix;
+ }
+ else
+ {
+ return $this->slash_item('base_url').$this->item('index_page').'?'.$this->_uri_string($uri);
+ }
+ }
+
+ // -------------------------------------------------------------
+
+ /**
+ * Base URL
+ * Returns base_url [. uri_string]
+ *
+ * @access public
+ * @param string $uri
+ * @return string
+ */
+ function base_url($uri = '')
+ {
+ return $this->slash_item('base_url').ltrim($this->_uri_string($uri),'/');
+ }
+
+ // -------------------------------------------------------------
+
+ /**
+ * Build URI string for use in Config::site_url() and Config::base_url()
+ *
+ * @access protected
+ * @param $uri
+ * @return string
+ */
+ protected function _uri_string($uri)
+ {
if ($this->item('enable_query_strings') == FALSE)
{
if (is_array($uri))
{
$uri = implode('/', $uri);
}
-
- $index = $this->item('index_page') == '' ? '' : $this->slash_item('index_page');
- $suffix = ($this->item('url_suffix') == FALSE) ? '' : $this->item('url_suffix');
- return $this->slash_item('base_url').$index.trim($uri, '/').$suffix;
+ $uri = trim($uri, '/');
}
else
{
@@ -253,16 +289,14 @@ class CI_Config {
$str .= $prefix.$key.'='.$val;
$i++;
}
-
$uri = $str;
}
-
- return $this->slash_item('base_url').$this->item('index_page').'?'.$uri;
}
+ return $uri;
}
// --------------------------------------------------------------------
-
+
/**
* System URL
*
diff --git a/system/helpers/url_helper.php b/system/helpers/url_helper.php
index d0516cee6..9f4b85248 100644
--- a/system/helpers/url_helper.php
+++ b/system/helpers/url_helper.php
@@ -50,18 +50,21 @@ if ( ! function_exists('site_url'))
/**
* Base URL
- *
- * Returns the "base_url" item from your config file
+ *
+ * Create a local URL based on your basepath.
+ * Segments can be passed in as a string or an array, same as site_url
+ * or a URL to a file can be passed in, e.g. to an image file.
*
* @access public
+ * @param string
* @return string
*/
if ( ! function_exists('base_url'))
{
- function base_url()
+ function base_url($uri = '')
{
$CI =& get_instance();
- return $CI->config->slash_item('base_url');
+ return $CI->config->base_url($uri);
}
}
--
cgit v1.2.3-24-g4f1b
From 76696d76e137e98f0597547b71b40a991d8b025b Mon Sep 17 00:00:00 2001
From: "anaxamaxan@blackdog.local"
Date: Wed, 2 Feb 2011 23:09:54 -0800
Subject: Added docs for config->base_url() changes.
---
user_guide/helpers/url_helper.html | 16 +++++++++++++++-
user_guide/libraries/config.html | 5 +++++
2 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/user_guide/helpers/url_helper.html b/user_guide/helpers/url_helper.html
index 6d8bdc240..de28a6f56 100644
--- a/user_guide/helpers/url_helper.html
+++ b/user_guide/helpers/url_helper.html
@@ -70,7 +70,7 @@ URL Helper
site_url()
Returns your site URL, as specified in your config file. The index.php file (or whatever you have set as your
-site index_page in your config file) will be added to the URL, as will any URI segments you pass to the function.
+site index_page in your config file) will be added to the URL, as will any URI segments you pass to the function, and the url_suffix as set in your config file.
You are encouraged to use this function any time you need to generate a local URL so that your pages become more portable
in the event your URL changes.
@@ -93,6 +93,20 @@ echo site_url($segments);
Returns your site base URL, as specified in your config file. Example:
echo base_url();
+This function returns the same thing as site_url, without the index_page or url_suffix being appended.
+
+Also like site_url, you can supply segments as a string or an array. Here is a string example:
+
+echo base_url("blog/post/123");
+
+The above example would return something like: http://example.com/blog/post/123
+
+This is useful because unlike site_url(), you can supply a string to a file, such as an image or stylesheet. For example:
+
+echo base_url("images/icons/edit.png");
+
+This would give you something like: http://example.com/images/icons/edit.png
+
current_url()
Returns the full URL (including segments) of the page being currently viewed.
diff --git a/user_guide/libraries/config.html b/user_guide/libraries/config.html
index 98b6052a9..103161f5d 100644
--- a/user_guide/libraries/config.html
+++ b/user_guide/libraries/config.html
@@ -175,6 +175,11 @@ define('ENVIRONMENT', 'development');
$this->config->site_url();
This function retrieves the URL to your site, along with the "index" value you've specified in the config file.
+$this->config->base_url();
+This function retrieves the URL to your site, plus an optional path such as to a stylesheet or image.
+
+The two functions above are normally accessed via the corresponding functions in the URL Helper.
+
$this->config->system_url();
This function retrieves the URL to your system folder.
--
cgit v1.2.3-24-g4f1b
From 84445d08e31c4d538d5a25023b8e5861804a8f14 Mon Sep 17 00:00:00 2001
From: Alex Bilbie
Date: Thu, 10 Mar 2011 16:43:39 +0000
Subject: Added sqlsrv folder, added necessary files, started altering queries
in sqlsrv_driver.php
---
system/database/drivers/sqlsrv/index.html | 10 +
system/database/drivers/sqlsrv/sqlsrv_driver.php | 664 ++++++++++++++++++++++
system/database/drivers/sqlsrv/sqlsrv_forge.php | 248 ++++++++
system/database/drivers/sqlsrv/sqlsrv_result.php | 169 ++++++
system/database/drivers/sqlsrv/sqlsrv_utility.php | 88 +++
5 files changed, 1179 insertions(+)
create mode 100644 system/database/drivers/sqlsrv/index.html
create mode 100644 system/database/drivers/sqlsrv/sqlsrv_driver.php
create mode 100644 system/database/drivers/sqlsrv/sqlsrv_forge.php
create mode 100644 system/database/drivers/sqlsrv/sqlsrv_result.php
create mode 100644 system/database/drivers/sqlsrv/sqlsrv_utility.php
diff --git a/system/database/drivers/sqlsrv/index.html b/system/database/drivers/sqlsrv/index.html
new file mode 100644
index 000000000..c942a79ce
--- /dev/null
+++ b/system/database/drivers/sqlsrv/index.html
@@ -0,0 +1,10 @@
+
+
+ 403 Forbidden
+
+
+
+Directory access is forbidden.
+
+
+
\ No newline at end of file
diff --git a/system/database/drivers/sqlsrv/sqlsrv_driver.php b/system/database/drivers/sqlsrv/sqlsrv_driver.php
new file mode 100644
index 000000000..d64e98108
--- /dev/null
+++ b/system/database/drivers/sqlsrv/sqlsrv_driver.php
@@ -0,0 +1,664 @@
+port != '')
+ {
+ $this->hostname .= ','.$this->port;
+ }
+
+ return @sqlsrv_connect($this->hostname, array('UID' => $this->username, 'PWD' => $this->password, 'Database' => $this->database, 'ConnectionPooling' => 0));
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Persistent database connection
+ *
+ * @access private called by the base class
+ * @return resource
+ */
+ function db_pconnect()
+ {
+ if ($this->port != '')
+ {
+ $this->hostname .= ','.$this->port;
+ }
+
+ return @sqlsrv_connect($this->hostname, array('UID' => $this->username, 'PWD' => $this->password, 'Database' => $this->database, 'ConnectionPooling' => 1));
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Reconnect
+ *
+ * Keep / reestablish the db connection if no queries have been
+ * sent for a length of time exceeding the server's idle timeout
+ *
+ * @access public
+ * @return void
+ */
+ function reconnect()
+ {
+ // not implemented in MSSQL
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Select the database
+ *
+ * @access private called by the base class
+ * @return resource
+ */
+ function db_select()
+ {
+ // Note: The brackets are required in the event that the DB name
+ // contains reserved characters
+ return @mssql_select_db('['.$this->database.']', $this->conn_id);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Set client character set
+ *
+ * @access public
+ * @param string
+ * @param string
+ * @return resource
+ */
+ function db_set_charset($charset, $collation)
+ {
+ // @todo - add support if needed
+ return TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Execute the query
+ *
+ * @access private called by the base class
+ * @param string an SQL query
+ * @return resource
+ */
+ function _execute($sql)
+ {
+ $sql = $this->_prep_query($sql);
+ return @sqlsrv_query($this->conn_id, $sql);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Prep the query
+ *
+ * If needed, each database adapter can prep the query string
+ *
+ * @access private called by execute()
+ * @param string an SQL query
+ * @return string
+ */
+ function _prep_query($sql)
+ {
+ return $sql;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Begin Transaction
+ *
+ * @access public
+ * @return bool
+ */
+ function trans_begin($test_mode = FALSE)
+ {
+ if ( ! $this->trans_enabled)
+ {
+ return TRUE;
+ }
+
+ // When transactions are nested we only begin/commit/rollback the outermost ones
+ if ($this->_trans_depth > 0)
+ {
+ return TRUE;
+ }
+
+ // Reset the transaction failure flag.
+ // If the $test_mode flag is set to TRUE transactions will be rolled back
+ // even if the queries produce a successful result.
+ $this->_trans_failure = ($test_mode === TRUE) ? TRUE : FALSE;
+
+ $this->simple_query('BEGIN TRAN');
+ return TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Commit Transaction
+ *
+ * @access public
+ * @return bool
+ */
+ function trans_commit()
+ {
+ if ( ! $this->trans_enabled)
+ {
+ return TRUE;
+ }
+
+ // When transactions are nested we only begin/commit/rollback the outermost ones
+ if ($this->_trans_depth > 0)
+ {
+ return TRUE;
+ }
+
+ $this->simple_query('COMMIT TRAN');
+ return TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Rollback Transaction
+ *
+ * @access public
+ * @return bool
+ */
+ function trans_rollback()
+ {
+ if ( ! $this->trans_enabled)
+ {
+ return TRUE;
+ }
+
+ // When transactions are nested we only begin/commit/rollback the outermost ones
+ if ($this->_trans_depth > 0)
+ {
+ return TRUE;
+ }
+
+ $this->simple_query('ROLLBACK TRAN');
+ return TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Escape String
+ *
+ * @access public
+ * @param string
+ * @param bool whether or not the string will be used in a LIKE condition
+ * @return string
+ */
+ function escape_str($str, $like = FALSE)
+ {
+ if (is_array($str))
+ {
+ foreach ($str as $key => $val)
+ {
+ $str[$key] = $this->escape_str($val, $like);
+ }
+
+ return $str;
+ }
+
+ // Escape single quotes
+ $str = str_replace("'", "''", remove_invisible_characters($str));
+
+ // escape LIKE condition wildcards
+ if ($like === TRUE)
+ {
+ $str = str_replace( array('%', '_', $this->_like_escape_chr),
+ array($this->_like_escape_chr.'%', $this->_like_escape_chr.'_', $this->_like_escape_chr.$this->_like_escape_chr),
+ $str);
+ }
+
+ return $str;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Affected Rows
+ *
+ * @access public
+ * @return integer
+ */
+ function affected_rows()
+ {
+ return @mssql_rows_affected($this->conn_id);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Insert ID
+ *
+ * Returns the last id created in the Identity column.
+ *
+ * @access public
+ * @return integer
+ */
+ function insert_id()
+ {
+ $ver = self::_parse_major_version($this->version());
+ $sql = ($ver >= 8 ? "SELECT SCOPE_IDENTITY() AS last_id" : "SELECT @@IDENTITY AS last_id");
+ $query = $this->query($sql);
+ $row = $query->row();
+ return $row->last_id;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Parse major version
+ *
+ * Grabs the major version number from the
+ * database server version string passed in.
+ *
+ * @access private
+ * @param string $version
+ * @return int16 major version number
+ */
+ function _parse_major_version($version)
+ {
+ preg_match('/([0-9]+)\.([0-9]+)\.([0-9]+)/', $version, $ver_info);
+ return $ver_info[1]; // return the major version b/c that's all we're interested in.
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Version number query string
+ *
+ * @access public
+ * @return string
+ */
+ function _version()
+ {
+ return "SELECT @@VERSION AS ver";
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * "Count All" query
+ *
+ * Generates a platform-specific query string that counts all records in
+ * the specified database
+ *
+ * @access public
+ * @param string
+ * @return string
+ */
+ function count_all($table = '')
+ {
+ if ($table == '')
+ {
+ return 0;
+ }
+
+ $query = $this->query($this->_count_string . $this->_protect_identifiers('numrows') . " FROM " . $this->_protect_identifiers($table, TRUE, NULL, FALSE));
+
+ if ($query->num_rows() == 0)
+ {
+ return 0;
+ }
+
+ $row = $query->row();
+ return (int) $row->numrows;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * List table query
+ *
+ * Generates a platform-specific query string so that the table names can be fetched
+ *
+ * @access private
+ * @param boolean
+ * @return string
+ */
+ function _list_tables($prefix_limit = FALSE)
+ {
+ $sql = "SELECT name FROM sysobjects WHERE type = 'U' ORDER BY name";
+
+ // for future compatibility
+ if ($prefix_limit !== FALSE AND $this->dbprefix != '')
+ {
+ //$sql .= " LIKE '".$this->escape_like_str($this->dbprefix)."%' ".sprintf($this->_like_escape_str, $this->_like_escape_chr);
+ return FALSE; // not currently supported
+ }
+
+ return $sql;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * List column query
+ *
+ * Generates a platform-specific query string so that the column names can be fetched
+ *
+ * @access private
+ * @param string the table name
+ * @return string
+ */
+ function _list_columns($table = '')
+ {
+ return "SELECT * FROM INFORMATION_SCHEMA.Columns WHERE TABLE_NAME = '".$table."'";
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Field data query
+ *
+ * Generates a platform-specific query so that the column data can be retrieved
+ *
+ * @access public
+ * @param string the table name
+ * @return object
+ */
+ function _field_data($table)
+ {
+ return "SELECT TOP 1 * FROM ".$table;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * The error message string
+ *
+ * @access private
+ * @return string
+ */
+ function _error_message()
+ {
+ return sqlsrv_errors();
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * The error message number
+ *
+ * @access private
+ * @return integer
+ */
+ function _error_number()
+ {
+ // Are error numbers supported?
+ return '';
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Escape the SQL Identifiers
+ *
+ * This function escapes column and table names
+ *
+ * @access private
+ * @param string
+ * @return string
+ */
+ function _escape_identifiers($item)
+ {
+ if ($this->_escape_char == '')
+ {
+ return $item;
+ }
+
+ foreach ($this->_reserved_identifiers as $id)
+ {
+ if (strpos($item, '.'.$id) !== FALSE)
+ {
+ $str = $this->_escape_char. str_replace('.', $this->_escape_char.'.', $item);
+
+ // remove duplicates if the user already included the escape
+ return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str);
+ }
+ }
+
+ if (strpos($item, '.') !== FALSE)
+ {
+ $str = $this->_escape_char.str_replace('.', $this->_escape_char.'.'.$this->_escape_char, $item).$this->_escape_char;
+ }
+ else
+ {
+ $str = $this->_escape_char.$item.$this->_escape_char;
+ }
+
+ // remove duplicates if the user already included the escape
+ return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * From Tables
+ *
+ * This function implicitly groups FROM tables so there is no confusion
+ * about operator precedence in harmony with SQL standards
+ *
+ * @access public
+ * @param type
+ * @return type
+ */
+ function _from_tables($tables)
+ {
+ if ( ! is_array($tables))
+ {
+ $tables = array($tables);
+ }
+
+ return implode(', ', $tables);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Insert statement
+ *
+ * Generates a platform-specific insert string from the supplied data
+ *
+ * @access public
+ * @param string the table name
+ * @param array the insert keys
+ * @param array the insert values
+ * @return string
+ */
+ function _insert($table, $keys, $values)
+ {
+ return "INSERT INTO ".$table." (".implode(', ', $keys).") VALUES (".implode(', ', $values).")";
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Update statement
+ *
+ * Generates a platform-specific update string from the supplied data
+ *
+ * @access public
+ * @param string the table name
+ * @param array the update data
+ * @param array the where clause
+ * @param array the orderby clause
+ * @param array the limit clause
+ * @return string
+ */
+ function _update($table, $values, $where, $orderby = array(), $limit = FALSE)
+ {
+ foreach ($values as $key => $val)
+ {
+ $valstr[] = $key." = ".$val;
+ }
+
+ $limit = ( ! $limit) ? '' : ' LIMIT '.$limit;
+
+ $orderby = (count($orderby) >= 1)?' ORDER BY '.implode(", ", $orderby):'';
+
+ $sql = "UPDATE ".$table." SET ".implode(', ', $valstr);
+
+ $sql .= ($where != '' AND count($where) >=1) ? " WHERE ".implode(" ", $where) : '';
+
+ $sql .= $orderby.$limit;
+
+ return $sql;
+ }
+
+
+ // --------------------------------------------------------------------
+
+ /**
+ * 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"
+ *
+ * @access public
+ * @param string the table name
+ * @return string
+ */
+ function _truncate($table)
+ {
+ return "TRUNCATE ".$table;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Delete statement
+ *
+ * Generates a platform-specific delete string from the supplied data
+ *
+ * @access public
+ * @param string the table name
+ * @param array the where clause
+ * @param string the limit clause
+ * @return string
+ */
+ function _delete($table, $where = array(), $like = array(), $limit = FALSE)
+ {
+ $conditions = '';
+
+ if (count($where) > 0 OR count($like) > 0)
+ {
+ $conditions = "\nWHERE ";
+ $conditions .= implode("\n", $this->ar_where);
+
+ if (count($where) > 0 && count($like) > 0)
+ {
+ $conditions .= " AND ";
+ }
+ $conditions .= implode("\n", $like);
+ }
+
+ $limit = ( ! $limit) ? '' : ' LIMIT '.$limit;
+
+ return "DELETE FROM ".$table.$conditions.$limit;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Limit string
+ *
+ * Generates a platform-specific LIMIT clause
+ *
+ * @access public
+ * @param string the sql query string
+ * @param integer the number of rows to limit the query to
+ * @param integer the offset value
+ * @return string
+ */
+ function _limit($sql, $limit, $offset)
+ {
+ $i = $limit + $offset;
+
+ return preg_replace('/(^\SELECT (DISTINCT)?)/i','\\1 TOP '.$i.' ', $sql);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Close DB Connection
+ *
+ * @access public
+ * @param resource
+ * @return void
+ */
+ function _close($conn_id)
+ {
+ @sqlsrv_close($conn_id);
+ }
+
+}
+
+
+
+/* End of file mssql_driver.php */
+/* Location: ./system/database/drivers/mssql/mssql_driver.php */
\ No newline at end of file
diff --git a/system/database/drivers/sqlsrv/sqlsrv_forge.php b/system/database/drivers/sqlsrv/sqlsrv_forge.php
new file mode 100644
index 000000000..70b20ecf8
--- /dev/null
+++ b/system/database/drivers/sqlsrv/sqlsrv_forge.php
@@ -0,0 +1,248 @@
+db->_escape_identifiers($table);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Create Table
+ *
+ * @access private
+ * @param string the table name
+ * @param array the fields
+ * @param mixed primary key(s)
+ * @param mixed key(s)
+ * @param boolean should 'IF NOT EXISTS' be added to the SQL
+ * @return bool
+ */
+ function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists)
+ {
+ $sql = 'CREATE TABLE ';
+
+ if ($if_not_exists === TRUE)
+ {
+ $sql .= 'IF NOT EXISTS ';
+ }
+
+ $sql .= $this->db->_escape_identifiers($table)." (";
+ $current_field_count = 0;
+
+ foreach ($fields as $field=>$attributes)
+ {
+ // Numeric field names aren't allowed in databases, so if the key is
+ // numeric, we know it was assigned by PHP and the developer manually
+ // entered the field information, so we'll simply add it to the list
+ if (is_numeric($field))
+ {
+ $sql .= "\n\t$attributes";
+ }
+ else
+ {
+ $attributes = array_change_key_case($attributes, CASE_UPPER);
+
+ $sql .= "\n\t".$this->db->_protect_identifiers($field);
+
+ $sql .= ' '.$attributes['TYPE'];
+
+ if (array_key_exists('CONSTRAINT', $attributes))
+ {
+ $sql .= '('.$attributes['CONSTRAINT'].')';
+ }
+
+ if (array_key_exists('UNSIGNED', $attributes) && $attributes['UNSIGNED'] === TRUE)
+ {
+ $sql .= ' UNSIGNED';
+ }
+
+ if (array_key_exists('DEFAULT', $attributes))
+ {
+ $sql .= ' DEFAULT \''.$attributes['DEFAULT'].'\'';
+ }
+
+ if (array_key_exists('NULL', $attributes) && $attributes['NULL'] === TRUE)
+ {
+ $sql .= ' NULL';
+ }
+ else
+ {
+ $sql .= ' NOT NULL';
+ }
+
+ if (array_key_exists('AUTO_INCREMENT', $attributes) && $attributes['AUTO_INCREMENT'] === TRUE)
+ {
+ $sql .= ' AUTO_INCREMENT';
+ }
+ }
+
+ // don't add a comma on the end of the last field
+ if (++$current_field_count < count($fields))
+ {
+ $sql .= ',';
+ }
+ }
+
+ if (count($primary_keys) > 0)
+ {
+ $primary_keys = $this->db->_protect_identifiers($primary_keys);
+ $sql .= ",\n\tPRIMARY KEY (" . implode(', ', $primary_keys) . ")";
+ }
+
+ if (is_array($keys) && count($keys) > 0)
+ {
+ foreach ($keys as $key)
+ {
+ if (is_array($key))
+ {
+ $key = $this->db->_protect_identifiers($key);
+ }
+ else
+ {
+ $key = array($this->db->_protect_identifiers($key));
+ }
+
+ $sql .= ",\n\tFOREIGN KEY (" . implode(', ', $key) . ")";
+ }
+ }
+
+ $sql .= "\n)";
+
+ return $sql;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Alter table query
+ *
+ * Generates a platform-specific query so that a table can be altered
+ * Called by add_column(), drop_column(), and column_alter(),
+ *
+ * @access private
+ * @param string the ALTER type (ADD, DROP, CHANGE)
+ * @param string the column name
+ * @param string the table name
+ * @param string the column definition
+ * @param string the default value
+ * @param boolean should 'NOT NULL' be added
+ * @param string the field after which we should add the new field
+ * @return object
+ */
+ function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '')
+ {
+ $sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table)." $alter_type ".$this->db->_protect_identifiers($column_name);
+
+ // DROP has everything it needs now.
+ if ($alter_type == 'DROP')
+ {
+ return $sql;
+ }
+
+ $sql .= " $column_definition";
+
+ if ($default_value != '')
+ {
+ $sql .= " DEFAULT \"$default_value\"";
+ }
+
+ if ($null === NULL)
+ {
+ $sql .= ' NULL';
+ }
+ else
+ {
+ $sql .= ' NOT NULL';
+ }
+
+ if ($after_field != '')
+ {
+ $sql .= ' AFTER ' . $this->db->_protect_identifiers($after_field);
+ }
+
+ return $sql;
+
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Rename a table
+ *
+ * Generates a platform-specific query so that a table can be renamed
+ *
+ * @access private
+ * @param string the old table name
+ * @param string the new table name
+ * @return string
+ */
+ function _rename_table($table_name, $new_table_name)
+ {
+ // I think this syntax will work, but can find little documentation on renaming tables in MSSQL
+ $sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table_name)." RENAME TO ".$this->db->_protect_identifiers($new_table_name);
+ return $sql;
+ }
+
+}
+
+/* End of file mssql_forge.php */
+/* Location: ./system/database/drivers/mssql/mssql_forge.php */
\ No newline at end of file
diff --git a/system/database/drivers/sqlsrv/sqlsrv_result.php b/system/database/drivers/sqlsrv/sqlsrv_result.php
new file mode 100644
index 000000000..2897ca5a5
--- /dev/null
+++ b/system/database/drivers/sqlsrv/sqlsrv_result.php
@@ -0,0 +1,169 @@
+result_id);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Number of fields in the result set
+ *
+ * @access public
+ * @return integer
+ */
+ function num_fields()
+ {
+ return @mssql_num_fields($this->result_id);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Fetch Field Names
+ *
+ * Generates an array of column names
+ *
+ * @access public
+ * @return array
+ */
+ function list_fields()
+ {
+ $field_names = array();
+ while ($field = mssql_fetch_field($this->result_id))
+ {
+ $field_names[] = $field->name;
+ }
+
+ return $field_names;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Field data
+ *
+ * Generates an array of objects containing field meta-data
+ *
+ * @access public
+ * @return array
+ */
+ function field_data()
+ {
+ $retval = array();
+ while ($field = mssql_fetch_field($this->result_id))
+ {
+ $F = new stdClass();
+ $F->name = $field->name;
+ $F->type = $field->type;
+ $F->max_length = $field->max_length;
+ $F->primary_key = 0;
+ $F->default = '';
+
+ $retval[] = $F;
+ }
+
+ return $retval;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Free the result
+ *
+ * @return null
+ */
+ function free_result()
+ {
+ if (is_resource($this->result_id))
+ {
+ mssql_free_result($this->result_id);
+ $this->result_id = FALSE;
+ }
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Data Seek
+ *
+ * Moves the internal pointer to the desired offset. We call
+ * this internally before fetching results to make sure the
+ * result set starts at zero
+ *
+ * @access private
+ * @return array
+ */
+ function _data_seek($n = 0)
+ {
+ return mssql_data_seek($this->result_id, $n);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Result - associative array
+ *
+ * Returns the result set as an array
+ *
+ * @access private
+ * @return array
+ */
+ function _fetch_assoc()
+ {
+ return mssql_fetch_assoc($this->result_id);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Result - object
+ *
+ * Returns the result set as an object
+ *
+ * @access private
+ * @return object
+ */
+ function _fetch_object()
+ {
+ return mssql_fetch_object($this->result_id);
+ }
+
+}
+
+
+/* End of file mssql_result.php */
+/* Location: ./system/database/drivers/mssql/mssql_result.php */
\ No newline at end of file
diff --git a/system/database/drivers/sqlsrv/sqlsrv_utility.php b/system/database/drivers/sqlsrv/sqlsrv_utility.php
new file mode 100644
index 000000000..48ecbc72a
--- /dev/null
+++ b/system/database/drivers/sqlsrv/sqlsrv_utility.php
@@ -0,0 +1,88 @@
+db->display_error('db_unsuported_feature');
+ }
+
+}
+
+/* End of file mssql_utility.php */
+/* Location: ./system/database/drivers/mssql/mssql_utility.php */
\ No newline at end of file
--
cgit v1.2.3-24-g4f1b
From d8cd2d42f0ba8a93c0a0c049f82d89fe624262a2 Mon Sep 17 00:00:00 2001
From: Alex Bilbie
Date: Thu, 10 Mar 2011 16:53:59 +0000
Subject: Added README
---
README.md | 8 ++++++++
1 file changed, 8 insertions(+)
create mode 100644 README.md
diff --git a/README.md b/README.md
new file mode 100644
index 000000000..8d587fb3c
--- /dev/null
+++ b/README.md
@@ -0,0 +1,8 @@
+CodeIgniter SQL Server Driver
+=============================
+
+PHP 5.3+ for Windows no longer supports the mssql functions because Microsoft are no longer supporting the underlying libraries used.
+
+Microsoft have developed a new set of drivers for SQL Server which they have committed to actively develop and support. These drivers can be downloaded here [http://sqlsrvphp.codeplex.com/](http://sqlsrvphp.codeplex.com/ "http://sqlsrvphp.codeplex.com/").
+
+This CodeIgniter fork will add support for these new drivers into the framework.
--
cgit v1.2.3-24-g4f1b
From 7e5127173c61752d827fc0c5bed1166ce040fabf Mon Sep 17 00:00:00 2001
From: Alex Bilbie
Date: Thu, 10 Mar 2011 16:55:31 +0000
Subject: Renamed README
---
README | 8 ++++++++
README.md | 8 --------
2 files changed, 8 insertions(+), 8 deletions(-)
create mode 100644 README
delete mode 100644 README.md
diff --git a/README b/README
new file mode 100644
index 000000000..8d587fb3c
--- /dev/null
+++ b/README
@@ -0,0 +1,8 @@
+CodeIgniter SQL Server Driver
+=============================
+
+PHP 5.3+ for Windows no longer supports the mssql functions because Microsoft are no longer supporting the underlying libraries used.
+
+Microsoft have developed a new set of drivers for SQL Server which they have committed to actively develop and support. These drivers can be downloaded here [http://sqlsrvphp.codeplex.com/](http://sqlsrvphp.codeplex.com/ "http://sqlsrvphp.codeplex.com/").
+
+This CodeIgniter fork will add support for these new drivers into the framework.
diff --git a/README.md b/README.md
deleted file mode 100644
index 8d587fb3c..000000000
--- a/README.md
+++ /dev/null
@@ -1,8 +0,0 @@
-CodeIgniter SQL Server Driver
-=============================
-
-PHP 5.3+ for Windows no longer supports the mssql functions because Microsoft are no longer supporting the underlying libraries used.
-
-Microsoft have developed a new set of drivers for SQL Server which they have committed to actively develop and support. These drivers can be downloaded here [http://sqlsrvphp.codeplex.com/](http://sqlsrvphp.codeplex.com/ "http://sqlsrvphp.codeplex.com/").
-
-This CodeIgniter fork will add support for these new drivers into the framework.
--
cgit v1.2.3-24-g4f1b
From 079069c2fa70b142fb4313f12f1fdf3f11713ff5 Mon Sep 17 00:00:00 2001
From: Alex Bilbie
Date: Thu, 10 Mar 2011 19:36:58 +0000
Subject: Think I've finished converting mssql commands to sqlsrv where
appropriate
---
system/database/drivers/sqlsrv/sqlsrv_driver.php | 4 +---
system/database/drivers/sqlsrv/sqlsrv_result.php | 16 ++++++++--------
2 files changed, 9 insertions(+), 11 deletions(-)
diff --git a/system/database/drivers/sqlsrv/sqlsrv_driver.php b/system/database/drivers/sqlsrv/sqlsrv_driver.php
index d64e98108..53d974837 100644
--- a/system/database/drivers/sqlsrv/sqlsrv_driver.php
+++ b/system/database/drivers/sqlsrv/sqlsrv_driver.php
@@ -107,9 +107,7 @@ class CI_DB_mssql_driver extends CI_DB {
*/
function db_select()
{
- // Note: The brackets are required in the event that the DB name
- // contains reserved characters
- return @mssql_select_db('['.$this->database.']', $this->conn_id);
+ // not implemented in sqlsrv
}
// --------------------------------------------------------------------
diff --git a/system/database/drivers/sqlsrv/sqlsrv_result.php b/system/database/drivers/sqlsrv/sqlsrv_result.php
index 2897ca5a5..058c6f478 100644
--- a/system/database/drivers/sqlsrv/sqlsrv_result.php
+++ b/system/database/drivers/sqlsrv/sqlsrv_result.php
@@ -34,7 +34,7 @@ class CI_DB_mssql_result extends CI_DB_result {
*/
function num_rows()
{
- return @mssql_num_rows($this->result_id);
+ return @sqlsrv_num_rows($this->result_id);
}
// --------------------------------------------------------------------
@@ -47,7 +47,7 @@ class CI_DB_mssql_result extends CI_DB_result {
*/
function num_fields()
{
- return @mssql_num_fields($this->result_id);
+ return @sqlsrv_num_fields($this->result_id);
}
// --------------------------------------------------------------------
@@ -63,7 +63,7 @@ class CI_DB_mssql_result extends CI_DB_result {
function list_fields()
{
$field_names = array();
- while ($field = mssql_fetch_field($this->result_id))
+ while ($field = sqlsrv_get_field($this->result_id))
{
$field_names[] = $field->name;
}
@@ -84,7 +84,7 @@ class CI_DB_mssql_result extends CI_DB_result {
function field_data()
{
$retval = array();
- while ($field = mssql_fetch_field($this->result_id))
+ while ($field = sqlsrv_get_field($this->result_id))
{
$F = new stdClass();
$F->name = $field->name;
@@ -110,7 +110,7 @@ class CI_DB_mssql_result extends CI_DB_result {
{
if (is_resource($this->result_id))
{
- mssql_free_result($this->result_id);
+ sqlsrv_free_stmt($this->result_id);
$this->result_id = FALSE;
}
}
@@ -129,7 +129,7 @@ class CI_DB_mssql_result extends CI_DB_result {
*/
function _data_seek($n = 0)
{
- return mssql_data_seek($this->result_id, $n);
+ // Not implemented
}
// --------------------------------------------------------------------
@@ -144,7 +144,7 @@ class CI_DB_mssql_result extends CI_DB_result {
*/
function _fetch_assoc()
{
- return mssql_fetch_assoc($this->result_id);
+ return sqlsrv_fetch_array($this->result_id, SQLSRV_FETCH_ASSOC);
}
// --------------------------------------------------------------------
@@ -159,7 +159,7 @@ class CI_DB_mssql_result extends CI_DB_result {
*/
function _fetch_object()
{
- return mssql_fetch_object($this->result_id);
+ return sqlsrv_fetch_object($this->result_id);
}
}
--
cgit v1.2.3-24-g4f1b
From 5336ee283c764a8f3ef9baa746324d7f6a26499f Mon Sep 17 00:00:00 2001
From: Alex Bilbie
Date: Sat, 12 Mar 2011 23:35:29 +0000
Subject: Added flag to return dates as strings instead of PHP date objects.
Updated db_select
---
system/database/drivers/sqlsrv/sqlsrv_driver.php | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/system/database/drivers/sqlsrv/sqlsrv_driver.php b/system/database/drivers/sqlsrv/sqlsrv_driver.php
index 53d974837..25cc628df 100644
--- a/system/database/drivers/sqlsrv/sqlsrv_driver.php
+++ b/system/database/drivers/sqlsrv/sqlsrv_driver.php
@@ -60,7 +60,7 @@ class CI_DB_mssql_driver extends CI_DB {
$this->hostname .= ','.$this->port;
}
- return @sqlsrv_connect($this->hostname, array('UID' => $this->username, 'PWD' => $this->password, 'Database' => $this->database, 'ConnectionPooling' => 0));
+ return @sqlsrv_connect($this->hostname, array('UID' => $this->username, 'PWD' => $this->password, 'Database' => $this->database, 'ConnectionPooling' => 0, 'ReturnDatesAsStrings' => 1));
}
// --------------------------------------------------------------------
@@ -78,7 +78,7 @@ class CI_DB_mssql_driver extends CI_DB {
$this->hostname .= ','.$this->port;
}
- return @sqlsrv_connect($this->hostname, array('UID' => $this->username, 'PWD' => $this->password, 'Database' => $this->database, 'ConnectionPooling' => 1));
+ return @sqlsrv_connect($this->hostname, array('UID' => $this->username, 'PWD' => $this->password, 'Database' => $this->database, 'ConnectionPooling' => 1, 'ReturnDatesAsStrings' => 1));
}
// --------------------------------------------------------------------
@@ -107,7 +107,7 @@ class CI_DB_mssql_driver extends CI_DB {
*/
function db_select()
{
- // not implemented in sqlsrv
+ return $this->_execute('USE ' . $this->database);
}
// --------------------------------------------------------------------
--
cgit v1.2.3-24-g4f1b
From 56e204079b8b3951abca5165ca815b75d37bf03d Mon Sep 17 00:00:00 2001
From: Alex Bilbie
Date: Sat, 12 Mar 2011 23:43:54 +0000
Subject: Updated affected_rows
---
system/database/drivers/sqlsrv/sqlsrv_driver.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/system/database/drivers/sqlsrv/sqlsrv_driver.php b/system/database/drivers/sqlsrv/sqlsrv_driver.php
index 25cc628df..e9c391786 100644
--- a/system/database/drivers/sqlsrv/sqlsrv_driver.php
+++ b/system/database/drivers/sqlsrv/sqlsrv_driver.php
@@ -283,7 +283,7 @@ class CI_DB_mssql_driver extends CI_DB {
*/
function affected_rows()
{
- return @mssql_rows_affected($this->conn_id);
+ return @sqlrv_rows_affected($this->conn_id);
}
// --------------------------------------------------------------------
--
cgit v1.2.3-24-g4f1b
From 01ab00469c80a26c22c61f896f0514dfcedccb67 Mon Sep 17 00:00:00 2001
From: Alex Bilbie
Date: Fri, 18 Mar 2011 19:24:30 +0000
Subject: Renamed some classes in the driver
---
system/database/drivers/sqlsrv/sqlsrv_driver.php | 4 ++--
system/database/drivers/sqlsrv/sqlsrv_forge.php | 4 ++--
system/database/drivers/sqlsrv/sqlsrv_result.php | 4 ++--
system/database/drivers/sqlsrv/sqlsrv_utility.php | 4 ++--
4 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/system/database/drivers/sqlsrv/sqlsrv_driver.php b/system/database/drivers/sqlsrv/sqlsrv_driver.php
index e9c391786..116907123 100644
--- a/system/database/drivers/sqlsrv/sqlsrv_driver.php
+++ b/system/database/drivers/sqlsrv/sqlsrv_driver.php
@@ -16,7 +16,7 @@
// ------------------------------------------------------------------------
/**
- * MS SQL Database Adapter Class
+ * SQLSRV Database Adapter Class
*
* Note: _DB is an extender class that the app controller
* creates dynamically based on whether the active record
@@ -28,7 +28,7 @@
* @author ExpressionEngine Dev Team
* @link http://codeigniter.com/user_guide/database/
*/
-class CI_DB_mssql_driver extends CI_DB {
+class CI_DB_sqlsrv_driver extends CI_DB {
var $dbdriver = 'sqlsrv';
diff --git a/system/database/drivers/sqlsrv/sqlsrv_forge.php b/system/database/drivers/sqlsrv/sqlsrv_forge.php
index 70b20ecf8..cc88ec5ca 100644
--- a/system/database/drivers/sqlsrv/sqlsrv_forge.php
+++ b/system/database/drivers/sqlsrv/sqlsrv_forge.php
@@ -16,13 +16,13 @@
// ------------------------------------------------------------------------
/**
- * MS SQL Forge Class
+ * SQLSRV Forge Class
*
* @category Database
* @author ExpressionEngine Dev Team
* @link http://codeigniter.com/user_guide/database/
*/
-class CI_DB_mssql_forge extends CI_DB_forge {
+class CI_DB_sqlsrv_forge extends CI_DB_forge {
/**
* Create database
diff --git a/system/database/drivers/sqlsrv/sqlsrv_result.php b/system/database/drivers/sqlsrv/sqlsrv_result.php
index 058c6f478..458200383 100644
--- a/system/database/drivers/sqlsrv/sqlsrv_result.php
+++ b/system/database/drivers/sqlsrv/sqlsrv_result.php
@@ -16,7 +16,7 @@
// ------------------------------------------------------------------------
/**
- * MS SQL Result Class
+ * SQLSRV Result Class
*
* This class extends the parent result class: CI_DB_result
*
@@ -24,7 +24,7 @@
* @author ExpressionEngine Dev Team
* @link http://codeigniter.com/user_guide/database/
*/
-class CI_DB_mssql_result extends CI_DB_result {
+class CI_DB_sqlsrv_result extends CI_DB_result {
/**
* Number of rows in the result set
diff --git a/system/database/drivers/sqlsrv/sqlsrv_utility.php b/system/database/drivers/sqlsrv/sqlsrv_utility.php
index 48ecbc72a..13a1850c4 100644
--- a/system/database/drivers/sqlsrv/sqlsrv_utility.php
+++ b/system/database/drivers/sqlsrv/sqlsrv_utility.php
@@ -16,13 +16,13 @@
// ------------------------------------------------------------------------
/**
- * MS SQL Utility Class
+ * SQLSRV Utility Class
*
* @category Database
* @author ExpressionEngine Dev Team
* @link http://codeigniter.com/user_guide/database/
*/
-class CI_DB_mssql_utility extends CI_DB_utility {
+class CI_DB_sqlsrv_utility extends CI_DB_utility {
/**
* List databases
--
cgit v1.2.3-24-g4f1b
From 3a43c7adae7737d68a0eeca663cc2dd3fc5b0cf3 Mon Sep 17 00:00:00 2001
From: Alex Bilbie
Date: Fri, 18 Mar 2011 19:48:04 +0000
Subject: Updates
---
system/database/drivers/sqlsrv/sqlsrv_driver.php | 206 ++++++++---------------
system/database/drivers/sqlsrv/sqlsrv_result.php | 20 +--
2 files changed, 81 insertions(+), 145 deletions(-)
diff --git a/system/database/drivers/sqlsrv/sqlsrv_driver.php b/system/database/drivers/sqlsrv/sqlsrv_driver.php
index 116907123..1d32792ce 100644
--- a/system/database/drivers/sqlsrv/sqlsrv_driver.php
+++ b/system/database/drivers/sqlsrv/sqlsrv_driver.php
@@ -53,14 +53,27 @@ class CI_DB_sqlsrv_driver extends CI_DB {
* @access private called by the base class
* @return resource
*/
- function db_connect()
+ function db_connect($pooling = false)
{
- if ($this->port != '')
- {
- $this->hostname .= ','.$this->port;
+ // Check for a UTF-8 charset being passed as CI's default 'utf8'.
+ $character_set = (0 === strcasecmp('utf8', $this->char_set)) ? 'UTF-8' : $this->char_set;
+
+ $connection = array(
+ 'UID' => empty($this->username) ? '' : $this->username,
+ 'PWD' => empty($this->password) ? '' : $this->password,
+ 'Database' => $this->database,
+ 'ConnectionPooling' => $pooling ? 1 : 0,
+ 'CharacterSet' => $character_set,
+ 'ReturnDatesAsStrings' => 1
+ );
+
+ // If the username and password are both empty, assume this is a
+ // 'Windows Authentication Mode' connection.
+ if(empty($connection['UID']) && empty($connection['PWD'])) {
+ unset($connection['UID'], $connection['PWD']);
}
- return @sqlsrv_connect($this->hostname, array('UID' => $this->username, 'PWD' => $this->password, 'Database' => $this->database, 'ConnectionPooling' => 0, 'ReturnDatesAsStrings' => 1));
+ return sqlsrv_connect($this->hostname, $connection);
}
// --------------------------------------------------------------------
@@ -73,12 +86,7 @@ class CI_DB_sqlsrv_driver extends CI_DB {
*/
function db_pconnect()
{
- if ($this->port != '')
- {
- $this->hostname .= ','.$this->port;
- }
-
- return @sqlsrv_connect($this->hostname, array('UID' => $this->username, 'PWD' => $this->password, 'Database' => $this->database, 'ConnectionPooling' => 1, 'ReturnDatesAsStrings' => 1));
+ $this->db_connect(TRUE);
}
// --------------------------------------------------------------------
@@ -138,7 +146,10 @@ class CI_DB_sqlsrv_driver extends CI_DB {
function _execute($sql)
{
$sql = $this->_prep_query($sql);
- return @sqlsrv_query($this->conn_id, $sql);
+ return sqlsrv_query($this->conn_id, $sql, null, array(
+ 'Scrollable' => SQLSRV_CURSOR_STATIC,
+ 'SendStreamParamsAtExec' => true
+ ));
}
// --------------------------------------------------------------------
@@ -183,8 +194,7 @@ class CI_DB_sqlsrv_driver extends CI_DB {
// even if the queries produce a successful result.
$this->_trans_failure = ($test_mode === TRUE) ? TRUE : FALSE;
- $this->simple_query('BEGIN TRAN');
- return TRUE;
+ return sqlsrv_begin_transaction($this->conn_id);
}
// --------------------------------------------------------------------
@@ -208,8 +218,7 @@ class CI_DB_sqlsrv_driver extends CI_DB {
return TRUE;
}
- $this->simple_query('COMMIT TRAN');
- return TRUE;
+ return sqlsrv_commit($this->conn_id);
}
// --------------------------------------------------------------------
@@ -233,8 +242,7 @@ class CI_DB_sqlsrv_driver extends CI_DB {
return TRUE;
}
- $this->simple_query('ROLLBACK TRAN');
- return TRUE;
+ return sqlsrv_rollback($this->conn_id);
}
// --------------------------------------------------------------------
@@ -249,28 +257,8 @@ class CI_DB_sqlsrv_driver extends CI_DB {
*/
function escape_str($str, $like = FALSE)
{
- if (is_array($str))
- {
- foreach ($str as $key => $val)
- {
- $str[$key] = $this->escape_str($val, $like);
- }
-
- return $str;
- }
-
// Escape single quotes
- $str = str_replace("'", "''", remove_invisible_characters($str));
-
- // escape LIKE condition wildcards
- if ($like === TRUE)
- {
- $str = str_replace( array('%', '_', $this->_like_escape_chr),
- array($this->_like_escape_chr.'%', $this->_like_escape_chr.'_', $this->_like_escape_chr.$this->_like_escape_chr),
- $str);
- }
-
- return $str;
+ return str_replace("'", "''", $str);
}
// --------------------------------------------------------------------
@@ -298,11 +286,7 @@ class CI_DB_sqlsrv_driver extends CI_DB {
*/
function insert_id()
{
- $ver = self::_parse_major_version($this->version());
- $sql = ($ver >= 8 ? "SELECT SCOPE_IDENTITY() AS last_id" : "SELECT @@IDENTITY AS last_id");
- $query = $this->query($sql);
- $row = $query->row();
- return $row->last_id;
+ return $this->query('select @@IDENTITY as insert_id')->row('insert_id');
}
// --------------------------------------------------------------------
@@ -333,7 +317,8 @@ class CI_DB_sqlsrv_driver extends CI_DB {
*/
function _version()
{
- return "SELECT @@VERSION AS ver";
+ $info = sqlsrv_server_info($this->conn_id);
+ return sprintf("select '%s' as ver", $info['SQLServerVersion']);
}
// --------------------------------------------------------------------
@@ -351,19 +336,15 @@ class CI_DB_sqlsrv_driver extends CI_DB {
function count_all($table = '')
{
if ($table == '')
- {
- return 0;
- }
-
- $query = $this->query($this->_count_string . $this->_protect_identifiers('numrows') . " FROM " . $this->_protect_identifiers($table, TRUE, NULL, FALSE));
-
+ return '0';
+
+ $query = $this->query("SELECT COUNT(*) AS numrows FROM " . $this->dbprefix . $table);
+
if ($query->num_rows() == 0)
- {
- return 0;
- }
+ return '0';
$row = $query->row();
- return (int) $row->numrows;
+ return $row->numrows;
}
// --------------------------------------------------------------------
@@ -379,16 +360,7 @@ class CI_DB_sqlsrv_driver extends CI_DB {
*/
function _list_tables($prefix_limit = FALSE)
{
- $sql = "SELECT name FROM sysobjects WHERE type = 'U' ORDER BY name";
-
- // for future compatibility
- if ($prefix_limit !== FALSE AND $this->dbprefix != '')
- {
- //$sql .= " LIKE '".$this->escape_like_str($this->dbprefix)."%' ".sprintf($this->_like_escape_str, $this->_like_escape_chr);
- return FALSE; // not currently supported
- }
-
- return $sql;
+ return "SELECT name FROM sysobjects WHERE type = 'U' ORDER BY name";
}
// --------------------------------------------------------------------
@@ -404,7 +376,7 @@ class CI_DB_sqlsrv_driver extends CI_DB {
*/
function _list_columns($table = '')
{
- return "SELECT * FROM INFORMATION_SCHEMA.Columns WHERE TABLE_NAME = '".$table."'";
+ return "SELECT * FROM INFORMATION_SCHEMA.Columns WHERE TABLE_NAME = '".$this->_escape_table($table)."'";
}
// --------------------------------------------------------------------
@@ -420,7 +392,7 @@ class CI_DB_sqlsrv_driver extends CI_DB {
*/
function _field_data($table)
{
- return "SELECT TOP 1 * FROM ".$table;
+ return "SELECT TOP 1 * FROM " . $this->_escape_table($table);
}
// --------------------------------------------------------------------
@@ -433,7 +405,8 @@ class CI_DB_sqlsrv_driver extends CI_DB {
*/
function _error_message()
{
- return sqlsrv_errors();
+ $error = array_shift(sqlsrv_errors());
+ return !empty($error['message']) ? $error['message'] : null;
}
// --------------------------------------------------------------------
@@ -446,12 +419,28 @@ class CI_DB_sqlsrv_driver extends CI_DB {
*/
function _error_number()
{
- // Are error numbers supported?
- return '';
+ $error = array_shift(sqlsrv_errors());
+ return isset($error['SQLSTATE']) ? $error['SQLSTATE'] : null;
}
// --------------------------------------------------------------------
+ /**
+ * Escape Table Name
+ *
+ * This function adds backticks if the table name has a period
+ * in it. Some DBs will get cranky unless periods are escaped
+ *
+ * @access private
+ * @param string the table name
+ * @return string
+ */
+ function _escape_table($table)
+ {
+ return $table;
+ }
+
+
/**
* Escape the SQL Identifiers
*
@@ -463,33 +452,7 @@ class CI_DB_sqlsrv_driver extends CI_DB {
*/
function _escape_identifiers($item)
{
- if ($this->_escape_char == '')
- {
- return $item;
- }
-
- foreach ($this->_reserved_identifiers as $id)
- {
- if (strpos($item, '.'.$id) !== FALSE)
- {
- $str = $this->_escape_char. str_replace('.', $this->_escape_char.'.', $item);
-
- // remove duplicates if the user already included the escape
- return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str);
- }
- }
-
- if (strpos($item, '.') !== FALSE)
- {
- $str = $this->_escape_char.str_replace('.', $this->_escape_char.'.'.$this->_escape_char, $item).$this->_escape_char;
- }
- else
- {
- $str = $this->_escape_char.$item.$this->_escape_char;
- }
-
- // remove duplicates if the user already included the escape
- return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str);
+ return $item;
}
// --------------------------------------------------------------------
@@ -528,8 +491,8 @@ class CI_DB_sqlsrv_driver extends CI_DB {
* @return string
*/
function _insert($table, $keys, $values)
- {
- return "INSERT INTO ".$table." (".implode(', ', $keys).") VALUES (".implode(', ', $values).")";
+ {
+ return "INSERT INTO ".$this->_escape_table($table)." (".implode(', ', $keys).") VALUES (".implode(', ', $values).")";
}
// --------------------------------------------------------------------
@@ -547,27 +510,16 @@ class CI_DB_sqlsrv_driver extends CI_DB {
* @param array the limit clause
* @return string
*/
- function _update($table, $values, $where, $orderby = array(), $limit = FALSE)
+ function _update($table, $values, $where)
{
- foreach ($values as $key => $val)
+ foreach($values as $key => $val)
{
$valstr[] = $key." = ".$val;
}
-
- $limit = ( ! $limit) ? '' : ' LIMIT '.$limit;
-
- $orderby = (count($orderby) >= 1)?' ORDER BY '.implode(", ", $orderby):'';
-
- $sql = "UPDATE ".$table." SET ".implode(', ', $valstr);
-
- $sql .= ($where != '' AND count($where) >=1) ? " WHERE ".implode(" ", $where) : '';
-
- $sql .= $orderby.$limit;
-
- return $sql;
+
+ return "UPDATE ".$this->_escape_table($table)." SET ".implode(', ', $valstr)." WHERE ".implode(" ", $where);
}
-
-
+
// --------------------------------------------------------------------
/**
@@ -599,25 +551,9 @@ class CI_DB_sqlsrv_driver extends CI_DB {
* @param string the limit clause
* @return string
*/
- function _delete($table, $where = array(), $like = array(), $limit = FALSE)
+ function _delete($table, $where)
{
- $conditions = '';
-
- if (count($where) > 0 OR count($like) > 0)
- {
- $conditions = "\nWHERE ";
- $conditions .= implode("\n", $this->ar_where);
-
- if (count($where) > 0 && count($like) > 0)
- {
- $conditions .= " AND ";
- }
- $conditions .= implode("\n", $like);
- }
-
- $limit = ( ! $limit) ? '' : ' LIMIT '.$limit;
-
- return "DELETE FROM ".$table.$conditions.$limit;
+ return "DELETE FROM ".$this->_escape_table($table)." WHERE ".implode(" ", $where);
}
// --------------------------------------------------------------------
@@ -636,8 +572,8 @@ class CI_DB_sqlsrv_driver extends CI_DB {
function _limit($sql, $limit, $offset)
{
$i = $limit + $offset;
-
- return preg_replace('/(^\SELECT (DISTINCT)?)/i','\\1 TOP '.$i.' ', $sql);
+
+ return preg_replace('/(^\SELECT (DISTINCT)?)/i','\\1 TOP '.$i.' ', $sql);
}
// --------------------------------------------------------------------
diff --git a/system/database/drivers/sqlsrv/sqlsrv_result.php b/system/database/drivers/sqlsrv/sqlsrv_result.php
index 458200383..bf0abd1c6 100644
--- a/system/database/drivers/sqlsrv/sqlsrv_result.php
+++ b/system/database/drivers/sqlsrv/sqlsrv_result.php
@@ -63,11 +63,11 @@ class CI_DB_sqlsrv_result extends CI_DB_result {
function list_fields()
{
$field_names = array();
- while ($field = sqlsrv_get_field($this->result_id))
+ foreach(sqlsrv_field_metadata($this->result_id) as $offset => $field)
{
- $field_names[] = $field->name;
+ $field_names[] = $field['Name'];
}
-
+
return $field_names;
}
@@ -84,18 +84,18 @@ class CI_DB_sqlsrv_result extends CI_DB_result {
function field_data()
{
$retval = array();
- while ($field = sqlsrv_get_field($this->result_id))
+ foreach(sqlsrv_field_metadata($this->result_id) as $offset => $field)
{
- $F = new stdClass();
- $F->name = $field->name;
- $F->type = $field->type;
- $F->max_length = $field->max_length;
+ $F = new stdClass();
+ $F->name = $field['Name'];
+ $F->type = $field['Type'];
+ $F->max_length = $field['Size'];
$F->primary_key = 0;
$F->default = '';
-
+
$retval[] = $F;
}
-
+
return $retval;
}
--
cgit v1.2.3-24-g4f1b
From 1f6f0abf0d17046a99fd9c9b3c60fb459b4531b1 Mon Sep 17 00:00:00 2001
From: Greg Aker
Date: Thu, 7 Apr 2011 18:24:53 -0500
Subject: Fixing a bug in the form_helper where csrf_token_name and csrf_hash
were referencing class properties in the Security class that were moved.
---
system/helpers/form_helper.php | 2 +-
user_guide/installation/upgrade_202.html | 2 ++
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/system/helpers/form_helper.php b/system/helpers/form_helper.php
index 8aa788c6c..acd75c239 100644
--- a/system/helpers/form_helper.php
+++ b/system/helpers/form_helper.php
@@ -67,7 +67,7 @@ if ( ! function_exists('form_open'))
// CSRF
if ($CI->config->item('csrf_protection') === TRUE)
{
- $hidden[$CI->security->csrf_token_name] = $CI->security->csrf_hash;
+ $hidden[$CI->security->get_csrf_token_name()] = $CI->security->get_csrf_hash();
}
if (is_array($hidden) AND count($hidden) > 0)
diff --git a/user_guide/installation/upgrade_202.html b/user_guide/installation/upgrade_202.html
index e6273f53c..d457d8bbb 100644
--- a/user_guide/installation/upgrade_202.html
+++ b/user_guide/installation/upgrade_202.html
@@ -76,6 +76,8 @@ Upgrading from 2.0.1 to 2.0.2
If you are overriding or extending the Security library, you will need to move it to application/core.
+csrf_token_name and csrf_hash have changed to protected class properties. Please use security->get_csrf_hash() and security->get_csrf_token_name() to access those values.
+
--
cgit v1.2.3-24-g4f1b
From bfbcf74c94a47c643420efaa342cc525bce2ad2c Mon Sep 17 00:00:00 2001
From: Greg Aker
Date: Thu, 7 Apr 2011 18:33:29 -0500
Subject: Fix: #192 CI version constant incorrect in core/CodeIgniter
---
system/core/CodeIgniter.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/system/core/CodeIgniter.php b/system/core/CodeIgniter.php
index f3e1439ff..e022e1b46 100644
--- a/system/core/CodeIgniter.php
+++ b/system/core/CodeIgniter.php
@@ -32,7 +32,7 @@
* Define the CodeIgniter Version
* ------------------------------------------------------
*/
- define('CI_VERSION', '2.0.1');
+ define('CI_VERSION', '2.0.2');
/*
* ------------------------------------------------------
--
cgit v1.2.3-24-g4f1b
From a439fb57decf98b5b630479e7ef5dc4e7f3360c9 Mon Sep 17 00:00:00 2001
From: Phil Sturgeon
Date: Fri, 8 Apr 2011 12:42:56 +0100
Subject: Updated Changelog to reflect "CLI usage" documentation being added.
---
user_guide/changelog.html | 1 +
1 file changed, 1 insertion(+)
diff --git a/user_guide/changelog.html b/user_guide/changelog.html
index d34f5c8f0..32f9ec84f 100644
--- a/user_guide/changelog.html
+++ b/user_guide/changelog.html
@@ -73,6 +73,7 @@ Hg Tag: n/a
Made Environment Support optional. Comment out or delete the constant to stop environment checks.
Added Environment Support for Hooks.
Added CI_ Prefix to the Cache driver.
+ Added CLI usage documentation.
Helpers
--
cgit v1.2.3-24-g4f1b
From b70e32ffae21c6a7ae4d21f2991a47f28531676f Mon Sep 17 00:00:00 2001
From: Phil Sturgeon
Date: Fri, 8 Apr 2011 12:44:17 +0100
Subject: Fixed bug with form_helper calling now protected variables.
---
system/helpers/form_helper.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/system/helpers/form_helper.php b/system/helpers/form_helper.php
index 8aa788c6c..acd75c239 100644
--- a/system/helpers/form_helper.php
+++ b/system/helpers/form_helper.php
@@ -67,7 +67,7 @@ if ( ! function_exists('form_open'))
// CSRF
if ($CI->config->item('csrf_protection') === TRUE)
{
- $hidden[$CI->security->csrf_token_name] = $CI->security->csrf_hash;
+ $hidden[$CI->security->get_csrf_token_name()] = $CI->security->get_csrf_hash();
}
if (is_array($hidden) AND count($hidden) > 0)
--
cgit v1.2.3-24-g4f1b
From 48bac74ea9fcb8eecdf97597647f1ed492d97b43 Mon Sep 17 00:00:00 2001
From: patwork
Date: Fri, 8 Apr 2011 13:46:47 +0200
Subject: Fix: codeigniter-reactor/193 incorrect driver filepaths
---
system/libraries/Driver.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/system/libraries/Driver.php b/system/libraries/Driver.php
index d1838f2c1..b942f539f 100644
--- a/system/libraries/Driver.php
+++ b/system/libraries/Driver.php
@@ -45,7 +45,7 @@ class CI_Driver_Library {
$child_class = $this->lib_name.'_'.$child;
// Remove the CI_ prefix and lowercase
- $lib_name = strtolower(preg_replace('/^CI_/', '', $this->lib_name));
+ $lib_name = ucfirst(strtolower(preg_replace('/^CI_/', '', $this->lib_name)));
$driver_name = strtolower(preg_replace('/^CI_/', '', $child_class));
if (in_array($driver_name, array_map('strtolower', $this->valid_drivers)))
@@ -226,4 +226,4 @@ class CI_Driver {
// END CI_Driver CLASS
/* End of file Driver.php */
-/* Location: ./system/libraries/Driver.php */
\ No newline at end of file
+/* Location: ./system/libraries/Driver.php */
--
cgit v1.2.3-24-g4f1b
From b07079827b084213463bdf576894faab172213f2 Mon Sep 17 00:00:00 2001
From: patwork
Date: Fri, 8 Apr 2011 15:10:05 +0200
Subject: Deals with language errors after codeigniter-reactor commit
r2307:c43c6dea56fb
---
system/libraries/Email.php | 44 ++++++++++++++++++++++----------------------
1 file changed, 22 insertions(+), 22 deletions(-)
diff --git a/system/libraries/Email.php b/system/libraries/Email.php
index 6c21f114d..cd89f8f3d 100644
--- a/system/libraries/Email.php
+++ b/system/libraries/Email.php
@@ -722,7 +722,7 @@ class CI_Email {
{
if ( ! is_array($email))
{
- $this->_set_error_message('email_must_be_array');
+ $this->_set_error_message('lang:email_must_be_array');
return FALSE;
}
@@ -730,7 +730,7 @@ class CI_Email {
{
if ( ! $this->valid_email($val))
{
- $this->_set_error_message('email_invalid_address', $val);
+ $this->_set_error_message('lang:email_invalid_address', $val);
return FALSE;
}
}
@@ -1131,7 +1131,7 @@ class CI_Email {
if ( ! file_exists($filename))
{
- $this->_set_error_message('email_attachment_missing', $filename);
+ $this->_set_error_message('lang:email_attachment_missing', $filename);
return FALSE;
}
@@ -1146,7 +1146,7 @@ class CI_Email {
if ( ! $fp = fopen($filename, FOPEN_READ))
{
- $this->_set_error_message('email_attachment_unreadable', $filename);
+ $this->_set_error_message('lang:email_attachment_unreadable', $filename);
return FALSE;
}
@@ -1353,7 +1353,7 @@ class CI_Email {
( ! isset($this->_bcc_array) AND ! isset($this->_headers['Bcc'])) AND
( ! isset($this->_headers['Cc'])))
{
- $this->_set_error_message('email_no_recipients');
+ $this->_set_error_message('lang:email_no_recipients');
return FALSE;
}
@@ -1484,7 +1484,7 @@ class CI_Email {
if ( ! $this->_send_with_mail())
{
- $this->_set_error_message('email_send_failure_phpmail');
+ $this->_set_error_message('lang:email_send_failure_phpmail');
return FALSE;
}
break;
@@ -1492,7 +1492,7 @@ class CI_Email {
if ( ! $this->_send_with_sendmail())
{
- $this->_set_error_message('email_send_failure_sendmail');
+ $this->_set_error_message('lang:email_send_failure_sendmail');
return FALSE;
}
break;
@@ -1500,14 +1500,14 @@ class CI_Email {
if ( ! $this->_send_with_smtp())
{
- $this->_set_error_message('email_send_failure_smtp');
+ $this->_set_error_message('lang:email_send_failure_smtp');
return FALSE;
}
break;
}
- $this->_set_error_message('email_sent', $this->_get_protocol());
+ $this->_set_error_message('lang:email_sent', $this->_get_protocol());
return TRUE;
}
@@ -1578,8 +1578,8 @@ class CI_Email {
if ($status != 0)
{
- $this->_set_error_message('email_exit_status', $status);
- $this->_set_error_message('email_no_socket');
+ $this->_set_error_message('lang:email_exit_status', $status);
+ $this->_set_error_message('lang:email_no_socket');
return FALSE;
}
@@ -1598,7 +1598,7 @@ class CI_Email {
{
if ($this->smtp_host == '')
{
- $this->_set_error_message('email_no_hostname');
+ $this->_set_error_message('lang:email_no_hostname');
return FALSE;
}
@@ -1647,7 +1647,7 @@ class CI_Email {
if (strncmp($reply, '250', 3) != 0)
{
- $this->_set_error_message('email_smtp_error', $reply);
+ $this->_set_error_message('lang:email_smtp_error', $reply);
return FALSE;
}
@@ -1674,7 +1674,7 @@ class CI_Email {
if ( ! is_resource($this->_smtp_connect))
{
- $this->_set_error_message('email_smtp_error', $errno." ".$errstr);
+ $this->_set_error_message('lang:email_smtp_error', $errno." ".$errstr);
return FALSE;
}
@@ -1737,7 +1737,7 @@ class CI_Email {
if (substr($reply, 0, 3) != $resp)
{
- $this->_set_error_message('email_smtp_error', $reply);
+ $this->_set_error_message('lang:email_smtp_error', $reply);
return FALSE;
}
@@ -1766,7 +1766,7 @@ class CI_Email {
if ($this->smtp_user == "" AND $this->smtp_pass == "")
{
- $this->_set_error_message('email_no_smtp_unpw');
+ $this->_set_error_message('lang:email_no_smtp_unpw');
return FALSE;
}
@@ -1776,7 +1776,7 @@ class CI_Email {
if (strncmp($reply, '334', 3) != 0)
{
- $this->_set_error_message('email_failed_smtp_login', $reply);
+ $this->_set_error_message('lang:email_failed_smtp_login', $reply);
return FALSE;
}
@@ -1786,7 +1786,7 @@ class CI_Email {
if (strncmp($reply, '334', 3) != 0)
{
- $this->_set_error_message('email_smtp_auth_un', $reply);
+ $this->_set_error_message('lang:email_smtp_auth_un', $reply);
return FALSE;
}
@@ -1796,7 +1796,7 @@ class CI_Email {
if (strncmp($reply, '235', 3) != 0)
{
- $this->_set_error_message('email_smtp_auth_pw', $reply);
+ $this->_set_error_message('lang:email_smtp_auth_pw', $reply);
return FALSE;
}
@@ -1815,7 +1815,7 @@ class CI_Email {
{
if ( ! fwrite($this->_smtp_connect, $data . $this->newline))
{
- $this->_set_error_message('email_smtp_data_failure', $data);
+ $this->_set_error_message('lang:email_smtp_data_failure', $data);
return FALSE;
}
else
@@ -1942,7 +1942,7 @@ class CI_Email {
$CI =& get_instance();
$CI->lang->load('email');
- if (FALSE === ($line = $CI->lang->line($msg)))
+ if (substr($msg, 0, 5) != 'lang:' || FALSE === ($line = $CI->lang->line(substr($msg, 5))))
{
$this->_debug_msg[] = str_replace('%s', $val, $msg)."
";
}
@@ -2059,4 +2059,4 @@ class CI_Email {
// END CI_Email class
/* End of file Email.php */
-/* Location: ./system/libraries/Email.php */
\ No newline at end of file
+/* Location: ./system/libraries/Email.php */
--
cgit v1.2.3-24-g4f1b
From 64e35cdcb9fd24787798c0f6ca3c0af45b0b904d Mon Sep 17 00:00:00 2001
From: patwork
Date: Fri, 8 Apr 2011 15:25:31 +0200
Subject: There is absolutely no need to specify class name (it will validate
anyway).
---
system/helpers/form_helper.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/system/helpers/form_helper.php b/system/helpers/form_helper.php
index acd75c239..bca0ff0c9 100644
--- a/system/helpers/form_helper.php
+++ b/system/helpers/form_helper.php
@@ -72,7 +72,7 @@ if ( ! function_exists('form_open'))
if (is_array($hidden) AND count($hidden) > 0)
{
- $form .= sprintf("\n%s
", form_hidden($hidden));
+ $form .= sprintf("\n%s
", form_hidden($hidden));
}
return $form;
@@ -1053,4 +1053,4 @@ if ( ! function_exists('_get_validation_object'))
/* End of file form_helper.php */
-/* Location: ./system/helpers/form_helper.php */
\ No newline at end of file
+/* Location: ./system/helpers/form_helper.php */
--
cgit v1.2.3-24-g4f1b
From 02404a1f59e4f3ae8231d87d8be5b23488ea86d2 Mon Sep 17 00:00:00 2001
From: patwork
Date: Fri, 8 Apr 2011 15:45:46 +0200
Subject: Fix: codeigniter-reactor/127 Form_validation rule error logging
---
system/libraries/Form_validation.php | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php
index cfc02eda9..6f79a554a 100644
--- a/system/libraries/Form_validation.php
+++ b/system/libraries/Form_validation.php
@@ -628,6 +628,10 @@ class CI_Form_validation {
$this->_field_data[$row['field']]['postdata'] = (is_bool($result)) ? $postdata : $result;
}
}
+ else
+ {
+ log_message('debug', "Unable to find validation rule: ".$rule);
+ }
continue;
}
@@ -1357,4 +1361,4 @@ class CI_Form_validation {
// END Form Validation Class
/* End of file Form_validation.php */
-/* Location: ./system/libraries/Form_validation.php */
\ No newline at end of file
+/* Location: ./system/libraries/Form_validation.php */
--
cgit v1.2.3-24-g4f1b
From ef1a55ad2875af3b2286a5b6eb9b65e997949f4d Mon Sep 17 00:00:00 2001
From: patwork
Date: Sat, 9 Apr 2011 13:04:06 +0200
Subject: Fix: codeigniter-reactor/199 CSRF config in Security class is no
longer ignored
---
system/core/Security.php | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/system/core/Security.php b/system/core/Security.php
index ceef9779c..73a3cfb31 100644
--- a/system/core/Security.php
+++ b/system/core/Security.php
@@ -58,6 +58,15 @@ class CI_Security {
*/
public function __construct()
{
+ // CSRF config
+ foreach(array('csrf_expire', 'csrf_token_name', 'csrf_cookie_name') as $key)
+ {
+ if (FALSE !== ($val = config_item($key)))
+ {
+ $this->{'_'.$key} = $val;
+ }
+ }
+
// Append application specific cookie prefix to token name
$this->_csrf_cookie_name = (config_item('cookie_prefix')) ? config_item('cookie_prefix').$this->_csrf_token_name : $this->_csrf_token_name;
@@ -817,4 +826,4 @@ class CI_Security {
// END Security Class
/* End of file Security.php */
-/* Location: ./system/libraries/Security.php */
\ No newline at end of file
+/* Location: ./system/libraries/Security.php */
--
cgit v1.2.3-24-g4f1b
From 571023b24f705d9c0bbaecf2e3cbbc06752390b4 Mon Sep 17 00:00:00 2001
From: patwork
Date: Mon, 11 Apr 2011 11:56:41 +0200
Subject: Fix: codeigniter-reactor/32 unicorns are no longer mute
---
system/core/Lang.php | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/system/core/Lang.php b/system/core/Lang.php
index 0b926a303..cdadc7f41 100644
--- a/system/core/Lang.php
+++ b/system/core/Lang.php
@@ -129,19 +129,19 @@ class CI_Lang {
*/
function line($line = '')
{
- $line = ($line == '' OR ! isset($this->language[$line])) ? FALSE : $this->language[$line];
+ $value = ($line == '' OR ! isset($this->language[$line])) ? FALSE : $this->language[$line];
// Because killer robots like unicorns!
- if ($line === FALSE)
+ if ($value === FALSE)
{
log_message('error', 'Could not find the language line "'.$line.'"');
}
- return $line;
+ return $value;
}
}
// END Language Class
/* End of file Lang.php */
-/* Location: ./system/core/Lang.php */
\ No newline at end of file
+/* Location: ./system/core/Lang.php */
--
cgit v1.2.3-24-g4f1b
From 9e2679849611ce050f5636c44b6c3279328d00f9 Mon Sep 17 00:00:00 2001
From: patwork
Date: Mon, 11 Apr 2011 13:02:32 +0200
Subject: Fix: codeigniter-reactor/199 cookie name was overwritten with token
name
---
system/core/Security.php | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/system/core/Security.php b/system/core/Security.php
index 73a3cfb31..4f91572ed 100644
--- a/system/core/Security.php
+++ b/system/core/Security.php
@@ -67,8 +67,10 @@ class CI_Security {
}
}
- // Append application specific cookie prefix to token name
- $this->_csrf_cookie_name = (config_item('cookie_prefix')) ? config_item('cookie_prefix').$this->_csrf_token_name : $this->_csrf_token_name;
+ // Append application specific cookie prefix
+ if (config_item('cookie_prefix')) {
+ $this->_csrf_cookie_name = config_item('cookie_prefix').$this->_csrf_cookie_name;
+ }
// Set the CSRF hash
$this->_csrf_set_hash();
--
cgit v1.2.3-24-g4f1b
From e70e92bab1de57a0749a31f2889b55cafb46d58e Mon Sep 17 00:00:00 2001
From: Greg Aker
Date: Mon, 25 Apr 2011 10:50:53 -0500
Subject: Fixing up a tabs vs spaces inconsistency in DB_Result
---
system/database/DB_result.php | 83 +++++++++++++++++++++++--------------------
1 file changed, 44 insertions(+), 39 deletions(-)
diff --git a/system/database/DB_result.php b/system/database/DB_result.php
index 06eec5124..e83228386 100644
--- a/system/database/DB_result.php
+++ b/system/database/DB_result.php
@@ -32,7 +32,7 @@ class CI_DB_result {
var $result_id = NULL;
var $result_array = array();
var $result_object = array();
- var $custom_result_object = array();
+ var $custom_result_object = array();
var $current_row = 0;
var $num_rows = 0;
var $row_data = NULL;
@@ -47,47 +47,52 @@ class CI_DB_result {
*/
function result($type = 'object')
{
- if ($type == 'array') return $this->result_array();
- else if ($type == 'object') return $this->result_object();
- else return $this->custom_result_object($type);
+ if ($type == 'array') return $this->result_array();
+ else if ($type == 'object') return $this->result_object();
+ else return $this->custom_result_object($type);
}
// --------------------------------------------------------------------
- /**
- * Custom query result.
- *
- * @param class_name A string that represents the type of object you want back
- * @return array of objects
- */
- function custom_result_object($class_name)
- {
- if (array_key_exists($class_name, $this->custom_result_object))
- {
- return $this->custom_result_object[$class_name];
- }
-
- if ($this->result_id === FALSE OR $this->num_rows() == 0)
- {
- return array();
- }
-
- // add the data to the object
- $this->_data_seek(0);
- $result_object = array();
+ /**
+ * Custom query result.
+ *
+ * @param class_name A string that represents the type of object you want back
+ * @return array of objects
+ */
+ function custom_result_object($class_name)
+ {
+ if (array_key_exists($class_name, $this->custom_result_object))
+ {
+ return $this->custom_result_object[$class_name];
+ }
+
+ if ($this->result_id === FALSE OR $this->num_rows() == 0)
+ {
+ return array();
+ }
+
+ // add the data to the object
+ $this->_data_seek(0);
+ $result_object = array();
+
while ($row = $this->_fetch_object())
- {
- $object = new $class_name();
- foreach ($row as $key => $value)
- {
- $object->$key = $value;
- }
+ {
+ $object = new $class_name();
+
+ foreach ($row as $key => $value)
+ {
+ $object->$key = $value;
+ }
+
$result_object[] = $object;
}
- // return the array
- return $this->custom_result_object[$class_name] = $result_object;
- }
+ // return the array
+ return $this->custom_result_object[$class_name] = $result_object;
+ }
+
+ // --------------------------------------------------------------------
/**
* Query result. "object" version.
@@ -180,9 +185,9 @@ class CI_DB_result {
$n = 0;
}
- if ($type == 'object') return $this->row_object($n);
- else if ($type == 'array') return $this->row_array($n);
- else return $this->custom_row_object($n, $type);
+ if ($type == 'object') return $this->row_object($n);
+ else if ($type == 'array') return $this->row_array($n);
+ else return $this->custom_row_object($n, $type);
}
// --------------------------------------------------------------------
@@ -219,7 +224,7 @@ class CI_DB_result {
// --------------------------------------------------------------------
- /**
+ /**
* Returns a single result row - custom object version
*
* @access public
@@ -242,7 +247,7 @@ class CI_DB_result {
return $result[$this->current_row];
}
- /**
+ /**
* Returns a single result row - object version
*
* @access public
--
cgit v1.2.3-24-g4f1b
From db60d240226468b19d656c4ba026bc992e4c3034 Mon Sep 17 00:00:00 2001
From: kenjis
Date: Fri, 15 Apr 2011 11:31:30 +0900
Subject: add "Using CodeIgniter Drivers" and "Creating Your Own Driver" in TOC
---
user_guide/nav/nav.js | 2 ++
user_guide/toc.html | 2 ++
2 files changed, 4 insertions(+)
diff --git a/user_guide/nav/nav.js b/user_guide/nav/nav.js
index ce783fc27..b44994d4d 100644
--- a/user_guide/nav/nav.js
+++ b/user_guide/nav/nav.js
@@ -50,6 +50,8 @@ function create_menu(basepath)
'Helpers' +
'Using CodeIgniter Libraries' +
'Creating Your Own Libraries' +
+ 'Using CodeIgniter Drivers' +
+ 'Creating Your Own Drivers' +
'Creating Core Classes' +
'Hooks - Extending the Core' +
'Auto-loading Resources' +
diff --git a/user_guide/toc.html b/user_guide/toc.html
index 4b4ab1001..f6a5fe0ec 100644
--- a/user_guide/toc.html
+++ b/user_guide/toc.html
@@ -103,6 +103,8 @@ Table of Contents
Helpers
Using CodeIgniter Libraries
Creating Your Own Libraries
+ Using CodeIgniter Drivers
+ Creating Your Own Drivers
Creating Core Classes
Hooks - Extending the Core
Auto-loading Resources
--
cgit v1.2.3-24-g4f1b
From e7bdd2260e6be61d3ed37e517f35ba017beee5f3 Mon Sep 17 00:00:00 2001
From: kenjis
Date: Fri, 15 Apr 2011 11:33:53 +0900
Subject: update Prev/Next Topic link on user_guide/database/index.html
---
user_guide/database/index.html | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/user_guide/database/index.html b/user_guide/database/index.html
index 594de80dd..1f0a1da7d 100644
--- a/user_guide/database/index.html
+++ b/user_guide/database/index.html
@@ -86,7 +86,7 @@ structures and Active Record patterns. The database functions offer clear, simpl
--
cgit v1.2.3-24-g4f1b
From 4c6ceb067ca15228c547770354023f826f552036 Mon Sep 17 00:00:00 2001
From: kenjis
Date: Fri, 15 Apr 2011 11:35:43 +0900
Subject: update Prev/Next Topic link on user_guide/helpers/array_helper.html
---
user_guide/helpers/array_helper.html | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/user_guide/helpers/array_helper.html b/user_guide/helpers/array_helper.html
index 88e8384d5..139bbe2b5 100644
--- a/user_guide/helpers/array_helper.html
+++ b/user_guide/helpers/array_helper.html
@@ -159,10 +159,10 @@ $this->post_model->update(elements(array('id', 'title', 'content'), $_POST));
--
cgit v1.2.3-24-g4f1b
From 33095c29a638c127928faa5b0360abd3ac5254f9 Mon Sep 17 00:00:00 2001
From: kenjis
Date: Fri, 15 Apr 2011 11:36:10 +0900
Subject: update Prev/Next Topic link on user_guide/helpers/captcha_helper.html
---
user_guide/helpers/captcha_helper.html | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/user_guide/helpers/captcha_helper.html b/user_guide/helpers/captcha_helper.html
index 3c6fa1188..c80c2fbe5 100644
--- a/user_guide/helpers/captcha_helper.html
+++ b/user_guide/helpers/captcha_helper.html
@@ -183,11 +183,11 @@ if ($row->count == 0)
--
cgit v1.2.3-24-g4f1b
From 49e31258bc85245b087d6b7b5ac02edb1b680bc6 Mon Sep 17 00:00:00 2001
From: kenjis
Date: Fri, 15 Apr 2011 11:37:15 +0900
Subject: update Prev/Next Topic link on user_guide/helpers/cookie_helper.html
---
user_guide/helpers/cookie_helper.html | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/user_guide/helpers/cookie_helper.html b/user_guide/helpers/cookie_helper.html
index 9879653c1..889c3346e 100644
--- a/user_guide/helpers/cookie_helper.html
+++ b/user_guide/helpers/cookie_helper.html
@@ -95,7 +95,7 @@ of values in the first parameter or you can set discrete parameters.
--
cgit v1.2.3-24-g4f1b
From 26eebddda5438c3967bad74a05c3e990528e1182 Mon Sep 17 00:00:00 2001
From: Eric Barnes
Date: Sun, 17 Apr 2011 23:45:41 -0400
Subject: Changed server check to ensure SCRIPT_NAME is defined. Fixes #57
---
system/core/URI.php | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/system/core/URI.php b/system/core/URI.php
index 80dc62e58..d56548654 100644
--- a/system/core/URI.php
+++ b/system/core/URI.php
@@ -120,7 +120,7 @@ class CI_URI {
$path = (isset($_SERVER[$uri])) ? $_SERVER[$uri] : @getenv($uri);
$this->_set_uri_string($path);
}
-
+
// --------------------------------------------------------------------
/**
@@ -133,7 +133,7 @@ class CI_URI {
{
// Filter out control characters
$str = remove_invisible_characters($str, FALSE);
-
+
// If the URI contains only a slash we'll kill it
$this->uri_string = ($str == '/') ? '' : $str;
}
@@ -151,7 +151,7 @@ class CI_URI {
*/
private function _detect_uri()
{
- if ( ! isset($_SERVER['REQUEST_URI']))
+ if ( ! isset($_SERVER['REQUEST_URI']) OR ! isset($_SERVER['SCRIPT_NAME']))
{
return '';
}
@@ -184,12 +184,12 @@ class CI_URI {
$_SERVER['QUERY_STRING'] = '';
$_GET = array();
}
-
+
if ($uri == '/' || empty($uri))
{
return '/';
}
-
+
$uri = parse_url($uri, PHP_URL_PATH);
// Do some final cleaning of the URI and return it
--
cgit v1.2.3-24-g4f1b
From c31b3729da50eaade365451f49dac7d462684702 Mon Sep 17 00:00:00 2001
From: Eric Barnes
Date: Sun, 17 Apr 2011 23:58:40 -0400
Subject: Added ENVIRONMENT to reserved constants. Fixes #196
---
user_guide/changelog.html | 17 +++++++++++++++++
user_guide/general/reserved_names.html | 1 +
2 files changed, 18 insertions(+)
diff --git a/user_guide/changelog.html b/user_guide/changelog.html
index f24d8110c..0ebe74ae6 100644
--- a/user_guide/changelog.html
+++ b/user_guide/changelog.html
@@ -59,6 +59,23 @@ Change Log
The indicates items that were contributed to CodeIgniter via CodeIgniter Reactor.
+Version 2.0.3
+Release Date: Not Released
+
+
+
+Bug fixes for 2.0.3
+
+ - Added ENVIRONMENT to reserved constants. (Reactor #196)
+ - Changed server check to ensure SCRIPT_NAME is defined. (Reactor #57)
+
+
Version 2.0.2
Release Date: April 7, 2011
Hg Tag: v2.0.2
diff --git a/user_guide/general/reserved_names.html b/user_guide/general/reserved_names.html
index d1ee2955b..00bebff61 100644
--- a/user_guide/general/reserved_names.html
+++ b/user_guide/general/reserved_names.html
@@ -90,6 +90,7 @@ is a list of reserved names. Do not name your controller any of these:
Constants
+ - ENVIRONMENT
- EXT
- FCPATH
- SELF
--
cgit v1.2.3-24-g4f1b
From bffb7769c6f31b7a47355d4eb66f5ac1d85c2a2e Mon Sep 17 00:00:00 2001
From: Eric Barnes
Date: Mon, 18 Apr 2011 00:03:31 -0400
Subject: Changed path in footer comment of cache dummy.
---
system/libraries/Cache/drivers/Cache_dummy.php | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/system/libraries/Cache/drivers/Cache_dummy.php b/system/libraries/Cache/drivers/Cache_dummy.php
index de47acb43..f96a68e27 100644
--- a/system/libraries/Cache/drivers/Cache_dummy.php
+++ b/system/libraries/Cache/drivers/Cache_dummy.php
@@ -10,29 +10,29 @@
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 2.0
- * @filesource
+ * @filesource
*/
// ------------------------------------------------------------------------
/**
- * CodeIgniter Dummy Caching Class
+ * CodeIgniter Dummy Caching Class
*
* @package CodeIgniter
* @subpackage Libraries
* @category Core
* @author ExpressionEngine Dev Team
- * @link
+ * @link
*/
class CI_Cache_dummy extends CI_Driver {
/**
- * Get
+ * Get
*
* Since this is the dummy class, it's always going to return FALSE.
*
- * @param string
+ * @param string
* @return Boolean FALSE
*/
public function get($id)
@@ -40,8 +40,8 @@ class CI_Cache_dummy extends CI_Driver {
return FALSE;
}
- // ------------------------------------------------------------------------
-
+ // ------------------------------------------------------------------------
+
/**
* Cache Save
*
@@ -55,7 +55,7 @@ class CI_Cache_dummy extends CI_Driver {
{
return TRUE;
}
-
+
// ------------------------------------------------------------------------
/**
@@ -112,7 +112,7 @@ class CI_Cache_dummy extends CI_Driver {
/**
* Is this caching driver supported on the system?
* Of course this one is.
- *
+ *
* @return TRUE;
*/
public function is_supported()
@@ -121,9 +121,9 @@ class CI_Cache_dummy extends CI_Driver {
}
// ------------------------------------------------------------------------
-
+
}
// End Class
-/* End of file Cache_apc.php */
-/* Location: ./system/libraries/Cache/drivers/Cache_apc.php */
\ No newline at end of file
+/* End of file Cache_dummy.php */
+/* Location: ./system/libraries/Cache/drivers/Cache_dummy.php */
\ No newline at end of file
--
cgit v1.2.3-24-g4f1b
From 826429cf40a9624788b92d2e6e4b7659e1b0d8a1 Mon Sep 17 00:00:00 2001
From: Greg Aker
Date: Mon, 18 Apr 2011 09:40:19 -0500
Subject: Added an optional third parameter to heading() which allows adding
html attributes to the rendered heading tag.
---
system/helpers/html_helper.php | 5 +++--
user_guide/changelog.html | 5 +++++
user_guide/helpers/html_helper.html | 5 +++++
3 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/system/helpers/html_helper.php b/system/helpers/html_helper.php
index c6103ab6f..a29204391 100644
--- a/system/helpers/html_helper.php
+++ b/system/helpers/html_helper.php
@@ -40,9 +40,10 @@
*/
if ( ! function_exists('heading'))
{
- function heading($data = '', $h = '1')
+ function heading($data = '', $h = '1', $attributes = '')
{
- return "".$data."";
+ $attributes = ($attributes != '') ? ' '.$attributes : $attributes;
+ return "".$data."";
}
}
diff --git a/user_guide/changelog.html b/user_guide/changelog.html
index 0ebe74ae6..0afc5b822 100644
--- a/user_guide/changelog.html
+++ b/user_guide/changelog.html
@@ -68,6 +68,11 @@ Change Log
+ Helpers
+
+ - Added an optional third parameter to heading() which allows adding html attributes to the rendered heading tag.
+
+
Bug fixes for 2.0.3
diff --git a/user_guide/helpers/html_helper.html b/user_guide/helpers/html_helper.html
index 1a0529f7b..308013d51 100644
--- a/user_guide/helpers/html_helper.html
+++ b/user_guide/helpers/html_helper.html
@@ -89,6 +89,11 @@ second the size of the heading. Example:
echo heading('Welcome!', 3);
The above would produce: <h3>Welcome!</h3>
+Additionally, in order to add attributes to the heading tag such as HTML classes, ids or inline styles, a third parameter is available.
+echo heading('Welcome!', 3, 'class="pink"')
+The above code produces: <h3 class="pink">Welcome!<<h3>
+
+
img()
Lets you create HTML <img /> tags. The first parameter contains the image source. Example:
echo img('images/picture.jpg');
--
cgit v1.2.3-24-g4f1b
From 62df13125bd9ab22ff0c7f2565a42a6de13ed7e4 Mon Sep 17 00:00:00 2001
From: Greg Aker
Date: Mon, 18 Apr 2011 11:18:02 -0500
Subject: Added Session Class userdata to the output profiler. Additionally,
added a show/hide toggle on HTTP Headers, Session Data and Config Variables.
---
system/language/english/profiler_lang.php | 3 +++
system/libraries/Profiler.php | 45 ++++++++++++++++++++++++++-----
user_guide/changelog.html | 2 +-
3 files changed, 43 insertions(+), 7 deletions(-)
diff --git a/system/language/english/profiler_lang.php b/system/language/english/profiler_lang.php
index b6460fb83..1111158c8 100644
--- a/system/language/english/profiler_lang.php
+++ b/system/language/english/profiler_lang.php
@@ -9,6 +9,7 @@ $lang['profiler_post_data'] = 'POST DATA';
$lang['profiler_uri_string'] = 'URI STRING';
$lang['profiler_memory_usage'] = 'MEMORY USAGE';
$lang['profiler_config'] = 'CONFIG VARIABLES';
+$lang['profiler_session_data'] = 'SESSION DATA';
$lang['profiler_headers'] = 'HTTP HEADERS';
$lang['profiler_no_db'] = 'Database driver is not currently loaded';
$lang['profiler_no_queries'] = 'No queries were run';
@@ -17,6 +18,8 @@ $lang['profiler_no_get'] = 'No GET data exists';
$lang['profiler_no_uri'] = 'No URI data exists';
$lang['profiler_no_memory'] = 'Memory Usage Unavailable';
$lang['profiler_no_profiles'] = 'No Profile data - all Profiler sections have been disabled.';
+$lang['profiler_section_hide'] = 'Hide';
+$lang['profiler_section_show'] = 'Show';
/* End of file profiler_lang.php */
/* Location: ./system/language/english/profiler_lang.php */
\ No newline at end of file
diff --git a/system/libraries/Profiler.php b/system/libraries/Profiler.php
index 8a1f18ced..d1828b984 100644
--- a/system/libraries/Profiler.php
+++ b/system/libraries/Profiler.php
@@ -32,7 +32,7 @@
*/
class CI_Profiler {
- var $CI;
+ private $CI;
protected $_available_sections = array(
'benchmarks',
@@ -43,6 +43,7 @@ class CI_Profiler {
'controller_info',
'queries',
'http_headers',
+ 'session_data',
'config'
);
@@ -410,10 +411,10 @@ class CI_Profiler {
$output = "\n\n";
$output .= '