summaryrefslogtreecommitdiffstats
path: root/user_guide_src/source/database
diff options
context:
space:
mode:
Diffstat (limited to 'user_guide_src/source/database')
-rw-r--r--user_guide_src/source/database/configuration.rst12
-rw-r--r--user_guide_src/source/database/query_builder.rst35
2 files changed, 45 insertions, 2 deletions
diff --git a/user_guide_src/source/database/configuration.rst b/user_guide_src/source/database/configuration.rst
index c17de600a..668496324 100644
--- a/user_guide_src/source/database/configuration.rst
+++ b/user_guide_src/source/database/configuration.rst
@@ -28,6 +28,8 @@ prototype::
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'autoinit' => TRUE,
+ 'encrypt' => FALSE,
+ 'compress' => FALSE,
'stricton' => FALSE,
'failover' => array()
);
@@ -69,6 +71,8 @@ These failovers can be specified by setting the failover for a connection like t
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'autoinit' => TRUE,
+ 'encrypt' => FALSE,
+ 'compress' => FALSE,
'stricton' => FALSE
),
array(
@@ -86,6 +90,8 @@ These failovers can be specified by setting the failover for a connection like t
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'autoinit' => TRUE,
+ 'encrypt' => FALSE,
+ 'compress' => FALSE,
'stricton' => FALSE
)
);
@@ -115,6 +121,8 @@ example, to set up a "test" environment you would do this::
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'autoinit' => TRUE,
+ 'compress' => FALSE,
+ 'encrypt' => FALSE,
'stricton' => FALSE,
'failover' => array()
);
@@ -174,11 +182,13 @@ Explanation of Values:
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.
+**encrypt** Whether or not to use an encrypted connection.
+**compress** Whether or not to use client compression (MySQL only).
**stricton** TRUE/FALSE (boolean) - Whether to force "Strict Mode" connections, good for ensuring strict SQL
while developing an application.
**port** The database port number. To use this value you have to add a line to the database config array.
::
-
+
$db['default']['port'] = 5432;
====================== ==================================================================================================
diff --git a/user_guide_src/source/database/query_builder.rst b/user_guide_src/source/database/query_builder.rst
index b86a0c8db..5380d0998 100644
--- a/user_guide_src/source/database/query_builder.rst
+++ b/user_guide_src/source/database/query_builder.rst
@@ -681,6 +681,35 @@ associative array of values.
.. note:: All values are escaped automatically producing safer queries.
+$this->db->replace()
+====================
+
+This method executes a REPLACE statement, which is basically the SQL
+standard for (optional) DELETE + INSERT, using *PRIMARY* and *UNIQUE*
+keys as the determining factor.
+In our case, it will save you from the need to implement complex
+logics with different combinations of ``select()``, ``update()``,
+``delete()`` and ``insert()`` calls.
+
+Example::
+
+ $data = array(
+ 'title' => 'My title',
+ 'name' => 'My Name',
+ 'date' => 'My date'
+ );
+
+ $this->db->replace('table', $data);
+
+ // Executes: REPLACE INTO mytable (title, name, date) VALUES ('My title', 'My name', 'My date')
+
+In the above example, if we assume that the *title* field is our primary
+key, then if a row containing 'My title' as the *title* value, that row
+will be deleted with our new row data replacing it.
+
+Usage of the ``set()`` method is also allowed and all fields are
+automatically escaped, just like with ``insert()``.
+
$this->db->set()
================
@@ -740,7 +769,6 @@ Or an object::
$this->db->set($object);
$this->db->insert('mytable');
-
*************
Updating Data
*************
@@ -792,6 +820,7 @@ Or as an array::
You may also use the $this->db->set() function described above when
performing updates.
+
$this->db->update_batch()
=========================
@@ -830,6 +859,10 @@ array of values, the third parameter is the where key.
.. note:: All values are escaped automatically producing safer queries.
+.. note:: ``affected_rows()`` won't give you proper results with this method,
+ due to the very nature of how it works. Instead, ``update_batch()``
+ returns the number of rows affected.
+
$this->db->get_compiled_update()
================================