From 3b9f88df882ee1af6fbc8ca4f299b1b229307895 Mon Sep 17 00:00:00 2001 From: Derek Jones Date: Fri, 20 May 2011 10:25:13 -0500 Subject: modified the 'use_set_names' variable in the MySQL/i drivers to be a class property instead of static, in case multiple database servers are connected to in a single request. Also clarified description of the 'dbcollat' setting in the configuration files --- user_guide/database/configuration.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'user_guide/database') diff --git a/user_guide/database/configuration.html b/user_guide/database/configuration.html index b34705410..439717748 100644 --- a/user_guide/database/configuration.html +++ b/user_guide/database/configuration.html @@ -132,7 +132,7 @@ for the primary connection, but it too can be renamed to something more relevant
  • cache_on - TRUE/FALSE (boolean) - Whether database query caching is enabled, see also Database Caching Class.
  • cachedir - The absolute server path to your database query cache directory.
  • char_set - The character set used in communicating with the database.
  • -
  • dbcollat - The character collation used in communicating with the database.

    Note: For MySQL and MySQLi databases, this setting is only used as a backup if your server is running PHP < 5.2.3 or MySQL < 5.0.7. There is an incompatibility in PHP with mysql_real_escape_string() which can make your site vulnerable to SQL injection if you are using a multi-byte character set and are running versions lower than these. Sites using Latin-1 or UTF-8 database character set and collation are unaffected.

  • +
  • dbcollat - The character collation used in communicating with the database.

    Note: For MySQL and MySQLi databases, this setting is only used as a backup if your server is running PHP < 5.2.3 or MySQL < 5.0.7 (and in table creation queries made with DB Forge). There is an incompatibility in PHP with mysql_real_escape_string() which can make your site vulnerable to SQL injection if you are using a multi-byte character set and are running versions lower than these. Sites using Latin-1 or UTF-8 database character set and collation are unaffected.

  • swap_pre - A default table prefix that should be swapped with dbprefix. This is useful for distributed applications where you might run manually written queries, and need the prefix to still be customizable by the end user.
  • autoinit - Whether or not to automatically connect to the database when the library loads. If set to false, the connection will take place prior to executing the first query.
  • stricton - TRUE/FALSE (boolean) - Whether to force "Strict Mode" connections, good for ensuring strict SQL while developing an application.
  • -- cgit v1.2.3-24-g4f1b From 37f4b9caa02783e06dd7c5318200113409a0deb1 Mon Sep 17 00:00:00 2001 From: Derek Jones Date: Fri, 1 Jul 2011 17:56:50 -0500 Subject: backed out 648b42a75739, which was a NON-trivial whitespace commit. It broke the Typography class's string replacements, for instance --- user_guide/database/active_record.html | 68 +++++++++++++++++----------------- user_guide/database/caching.html | 34 ++++++++--------- user_guide/database/call_function.html | 8 ++-- user_guide/database/configuration.html | 18 ++++----- user_guide/database/connecting.html | 6 +-- user_guide/database/examples.html | 12 +++--- user_guide/database/fields.html | 4 +- user_guide/database/forge.html | 10 ++--- user_guide/database/helpers.html | 12 +++--- user_guide/database/index.html | 2 +- user_guide/database/queries.html | 14 +++---- user_guide/database/results.html | 20 +++++----- user_guide/database/table_data.html | 6 +-- user_guide/database/transactions.html | 14 +++---- user_guide/database/utilities.html | 18 ++++----- 15 files changed, 123 insertions(+), 123 deletions(-) (limited to 'user_guide/database') diff --git a/user_guide/database/active_record.html b/user_guide/database/active_record.html index 566b260c9..62833813c 100644 --- a/user_guide/database/active_record.html +++ b/user_guide/database/active_record.html @@ -59,12 +59,12 @@ Active Record

    CodeIgniter uses a modified version of the Active Record Database Pattern. This pattern allows information to be retrieved, inserted, and updated in your database with minimal scripting. In some cases only one or two lines of code are necessary to perform a database action. -CodeIgniter does not require that each database table be its own class file. It instead provides a more simplified interface.

    +CodeIgniter does not require that each database table be its own class file. It instead provides a more simplified interface.

    Beyond simplicity, a major benefit to using the Active Record features is that it allows you to create database independent applications, since the query syntax -is generated by each database adapter. It also allows for safer queries, since the values are escaped automatically by the system.

    +is generated by each database adapter. It also allows for safer queries, since the values are escaped automatically by the system.

    -

    Note: If you intend to write your own queries you can disable this class in your database config file, allowing the core database library and adapter to utilize fewer resources.

    +

    Note: If you intend to write your own queries you can disable this class in your database config file, allowing the core database library and adapter to utilize fewer resources.

    Note: Depending on what database platform you are using (MySQL, Postgres, etc.) -not all values will be needed. For example, when using SQLite you will not need to supply a username or password, and +not all values will be needed. For example, when using SQLite you will not need to supply a username or password, and the database name will be the path to your database file. The information above assumes you are using MySQL.

    diff --git a/user_guide/database/connecting.html b/user_guide/database/connecting.html index 1a74f5571..bb1b401f9 100644 --- a/user_guide/database/connecting.html +++ b/user_guide/database/connecting.html @@ -84,8 +84,8 @@ to the group specified in your database config file. For most people, this is th
    1. The database connection values, passed either as an array or a DSN string.
    2. -
    3. TRUE/FALSE (boolean). Whether to return the connection ID (see Connecting to Multiple Databases below).
    4. -
    5. TRUE/FALSE (boolean). Whether to enable the Active Record class. Set to TRUE by default.
    6. +
    7. TRUE/FALSE (boolean). Whether to return the connection ID (see Connecting to Multiple Databases below).
    8. +
    9. TRUE/FALSE (boolean). Whether to enable the Active Record class. Set to TRUE by default.
    @@ -148,7 +148,7 @@ you can pass the connection values as indicated above).

    By setting the second parameter to TRUE (boolean) the function will return the database object.

    -

    When you connect this way, you will use your object name to issue commands rather than the syntax used throughout this guide. In other words, rather than issuing commands with:

    +

    When you connect this way, you will use your object name to issue commands rather than the syntax used throughout this guide. In other words, rather than issuing commands with:

    $this->db->query();
    $this->db->result();
    etc...

    diff --git a/user_guide/database/examples.html b/user_guide/database/examples.html index 6bb8beb32..535fa3177 100644 --- a/user_guide/database/examples.html +++ b/user_guide/database/examples.html @@ -61,7 +61,7 @@ Database Example Code

    Database Quick Start: Example Code

    -

    The following page contains example code showing how the database class is used. For complete details please +

    The following page contains example code showing how the database class is used. For complete details please read the individual pages describing each function.

    @@ -73,7 +73,7 @@ read the individual pages describing each function.

    Once loaded the class is ready to be used as described below.

    -

    Note: If all your pages require database access you can connect automatically. See the connecting page for details.

    +

    Note: If all your pages require database access you can connect automatically. See the connecting page for details.

    Standard Query With Multiple Results (Object Version)

    @@ -90,7 +90,7 @@ foreach ($query->result() as $row)
    echo 'Total Results: ' . $query->num_rows(); -

    The above result() function returns an array of objects. Example: $row->title

    +

    The above result() function returns an array of objects. Example: $row->title

    Standard Query With Multiple Results (Array Version)

    @@ -104,7 +104,7 @@ foreach ($query->result_array() as $row)
        echo $row['email'];
    } -

    The above result_array() function returns an array of standard array indexes. Example: $row['title']

    +

    The above result_array() function returns an array of standard array indexes. Example: $row['title']

    Testing for Results

    @@ -137,7 +137,7 @@ $row = $query->row();
    echo $row->name;
    -

    The above row() function returns an object. Example: $row->name

    +

    The above row() function returns an object. Example: $row->name

    Standard Query With Single Result (Array version)

    @@ -148,7 +148,7 @@ $row = $query->row_array();
    echo $row['name'];
    -

    The above row_array() function returns an array. Example: $row['name']

    +

    The above row_array() function returns an array. Example: $row['name']

    Standard Insert

    diff --git a/user_guide/database/fields.html b/user_guide/database/fields.html index b20436129..04d8b8096 100644 --- a/user_guide/database/fields.html +++ b/user_guide/database/fields.html @@ -92,7 +92,7 @@ foreach ($query->list_fields() as $field)

    $this->db->field_exists()

    Sometimes it's helpful to know whether a particular field exists before performing an action. -Returns a boolean TRUE/FALSE. Usage example:

    +Returns a boolean TRUE/FALSE. Usage example:

    if ($this->db->field_exists('field_name', 'table_name'))
    @@ -101,7 +101,7 @@ if ($this->db->field_exists('field_name', 'table_name'))
    }
    -

    Note: Replace field_name with the name of the column you are looking for, and replace +

    Note: Replace field_name with the name of the column you are looking for, and replace table_name with the name of the table you are looking for.

    diff --git a/user_guide/database/forge.html b/user_guide/database/forge.html index bbef053e4..cad2cf26f 100644 --- a/user_guide/database/forge.html +++ b/user_guide/database/forge.html @@ -151,7 +151,7 @@ already be running, since the forge class relies on it.

                                              ),
                    );

    -

    After the fields have been defined, they can be added using $this->dbforge->add_field($fields); followed by a call to the create_table() function.

    +

    After the fields have been defined, they can be added using $this->dbforge->add_field($fields); followed by a call to the create_table() function.

    $this->dbforge->add_field()

    The add fields function will accept the above array.

    Passing strings as fields

    @@ -164,7 +164,7 @@ already be running, since the forge class relies on it.

    // gives id INT(9) NOT NULL AUTO_INCREMENT

    Adding Keys

    Generally speaking, you'll want your table to have Keys. This is accomplished with $this->dbforge->add_key('field'). An optional second parameter set to TRUE will make it a primary key. Note that add_key() must be followed by a call to create_table().

    -

    Multiple column non-primary keys must be sent as an array. Sample output below is for MySQL.

    +

    Multiple column non-primary keys must be sent as an array. Sample output below is for MySQL.

    $this->dbforge->add_key('blog_id', TRUE);
    // gives PRIMARY KEY `blog_id` (`blog_id`)

    @@ -187,7 +187,7 @@ already be running, since the forge class relies on it.

    Dropping a table

    Executes a DROP TABLE sql

    $this->dbforge->drop_table('table_name');
    - // gives DROP TABLE IF EXISTS table_name

    + // gives DROP TABLE IF EXISTS table_name

    Renaming a table

    Executes a TABLE rename

    $this->dbforge->rename_table('old_table_name', 'new_table_name');
    @@ -200,7 +200,7 @@ already be running, since the forge class relies on it.

    );
    $this->dbforge->add_column('table_name', $fields);

    -// gives ALTER TABLE table_name ADD preferences TEXT

    +// gives ALTER TABLE table_name ADD preferences TEXT

    $this->dbforge->drop_column()

    Used to remove a column from a table.

    $this->dbforge->drop_column('table_name', 'column_to_drop');

    @@ -214,7 +214,7 @@ $this->dbforge->add_column('table_name', $fields);
    );
    $this->dbforge->modify_column('table_name', $fields);

    - // gives ALTER TABLE table_name CHANGE old_name new_name TEXT

    + // gives ALTER TABLE table_name CHANGE old_name new_name TEXT

     

    diff --git a/user_guide/database/helpers.html b/user_guide/database/helpers.html index 650dd7a0b..107d2ed85 100644 --- a/user_guide/database/helpers.html +++ b/user_guide/database/helpers.html @@ -67,12 +67,12 @@ Query Helpers

    $this->db->affected_rows()

    Displays the number of affected rows, when doing "write" type queries (insert, update, etc.).

    -

    Note: In MySQL "DELETE FROM TABLE" returns 0 affected rows. The database class has a small hack that allows it to return the -correct number of affected rows. By default this hack is enabled but it can be turned off in the database driver file.

    +

    Note: In MySQL "DELETE FROM TABLE" returns 0 affected rows. The database class has a small hack that allows it to return the +correct number of affected rows. By default this hack is enabled but it can be turned off in the database driver file.

    $this->db->count_all();

    -

    Permits you to determine the number of rows in a particular table. Submit the table name in the first parameter. Example:

    +

    Permits you to determine the number of rows in a particular table. Submit the table name in the first parameter. Example:

    echo $this->db->count_all('my_table');

    // Produces an integer, like 25 @@ -90,11 +90,11 @@ correct number of affected rows. By default this hack is enabled but it can be t

    $this->db->last_query();

    -

    Returns the last query that was run (the query string, not the result). Example:

    +

    Returns the last query that was run (the query string, not the result). Example:

    $str = $this->db->last_query();

    -// Produces: SELECT * FROM sometable.... +// Produces: SELECT * FROM sometable....
    @@ -109,7 +109,7 @@ correct number of affected rows. By default this hack is enabled but it can be t $str = $this->db->insert_string('table_name', $data);
    -

    The first parameter is the table name, the second is an associative array with the data to be inserted. The above example produces:

    +

    The first parameter is the table name, the second is an associative array with the data to be inserted. The above example produces:

    INSERT INTO table_name (name, email, url) VALUES ('Rick', 'rick@example.com', 'example.com')

    Note: Values are automatically escaped, producing safer queries.

    diff --git a/user_guide/database/index.html b/user_guide/database/index.html index 594de80dd..fa3548cf1 100644 --- a/user_guide/database/index.html +++ b/user_guide/database/index.html @@ -63,7 +63,7 @@ Database Library structures and Active Record patterns. The database functions offer clear, simple syntax.