[commits] [Wiki] changed: Doc/Dev/HordeDb

2020-05-07 Thread Wiki Guest

guest [89.12.183.15]  Thu, 07 May 2020 09:11:51 +

Modified page: https://wiki.horde.org/Doc/Dev/HordeDb
New Revision:  3
Change log:  Transferred the part about unique keys to the right section

@@ -66,19 +66,18 @@
 if (!$this->hasIndex('my_table', array('my_column', 'my_column2'))) {
 $this->addIndex('my_table', array('my_column', 'my_column2'));
 }
 
+
 Adding a unique key / unique index

 It's also possible to add unique keys or a self defined names via  
the options:

-
+
 
 if (!$this->hasIndex('my_table', 'my_column')) {
 $this->addIndex('my_table', 'my_column', array('unique' => true));
 }
 
-
-
-+++ Adding a unique key / unique index

 +++ Converting for Non-Horde or Pre-H4 schemas

 Check for all table's existence before adding them

--
commits mailing list
Frequently Asked Questions: http://wiki.horde.org/FAQ
To unsubscribe, mail: commits-unsubscr...@lists.horde.org


[commits] [Wiki] changed: Doc/Dev/HordeDb

2020-05-07 Thread Wiki Guest

guest [89.12.183.15]  Thu, 07 May 2020 09:10:17 +

Modified page: https://wiki.horde.org/Doc/Dev/HordeDb
New Revision:  2
Change log:  Added explanation on how to set indeces

@@ -35,8 +35,47 @@
 +++ Dropping a column from an existing table


 +++ Adding an index
+
+It's possible to use a helper function to check if an index is already set:
+
+
+/**
+ * Helper function to test if an index already exists
+ */
+private function hasIndex($tableName, $column)
+{
+$indexedColumns = array();
+foreach ($this->indexes($tableName) as $index) {
+$indexedColumns = array_merge($indexedColumns, $index->columns);
+}
+
+if (is_array($column)) {
+foreach ($column as $entry) {
+return in_array($entry, $indexedColumns);
+}
+} else {
+return in_array($column, $indexedColumns);
+}
+}
+
+
+Add the index
+
+
+if (!$this->hasIndex('my_table', array('my_column', 'my_column2'))) {
+$this->addIndex('my_table', array('my_column', 'my_column2'));
+}
+
+
+It's also possible to add unique keys or a self defined names via the  
options:

+
+
+if (!$this->hasIndex('my_table', 'my_column')) {
+$this->addIndex('my_table', 'my_column', array('unique' => true));
+}
+


 +++ Adding a unique key / unique index


--
commits mailing list
Frequently Asked Questions: http://wiki.horde.org/FAQ
To unsubscribe, mail: commits-unsubscr...@lists.horde.org


[commits] [Wiki] changed: Doc/Dev/HordeHistory

2020-05-07 Thread Wiki Guest

guest [37.4.228.151]  Thu, 07 May 2020 08:56:13 +

Modified page: https://wiki.horde.org/Doc/Dev/HordeHistory
New Revision:  4
Change log:  formatting

@@ -6,11 +6,13 @@
 Possible use cases are sync protocols, undo/rewind features or human  
consumable history information. The Horde_Activesync implementation  
uses Horde_Histories to track create/delete/update events of syncable  
items.


 ++ General Usage
 Create an implementation of the Horde_History class and fulfill its  
dependencies
-$history = new Horde_History_Sql($username, Horde_Db_Adapter  
$db);

+$history = new Horde_History_Sql($username, Horde_Db_Adapter $db);
+

 Log events related to a $guid identifying the resource tracked
+
 
 $history->log('room1:shelf1:item100', array(
 'who' => 'someuser', // defaults to the user provided at  
construction of the object

 'action' => 'create',

--
commits mailing list
Frequently Asked Questions: http://wiki.horde.org/FAQ
To unsubscribe, mail: commits-unsubscr...@lists.horde.org


[commits] [Wiki] changed: Doc/Dev

2020-05-07 Thread Wiki Guest

guest [37.4.228.151]  Thu, 07 May 2020 08:51:58 +

Modified page: https://wiki.horde.org/Doc/Dev
New Revision:  137
Change log:  Add Horde_Db

@@ -40,8 +40,9 @@
   * ((Doc/Dev/HordeArgvAdvanced|Advanced Usage))
   * ((Doc/Dev/HordeArgvExtend|Extending Horde_Argv))
   * ((Doc/Dev/HordeArgvCallbacks|Option Callbacks))
 * ((Doc/Dev/HordeCliModular|Horde_Cli_Modular))
+* ((Doc/Dev/HordeDb|Horde_Db and Migrations usage examples))
 * ((Doc/Dev/HordeHistory|Horde_History))
 * ((Doc/Dev/Imap_Client|Horde_Imap_Client))
 * ((Doc/Dev/Injector|Horde_Injector))
 * ((Doc/Dev/HordeKolabFormat|Horde_Kolab_Format))

--
commits mailing list
Frequently Asked Questions: http://wiki.horde.org/FAQ
To unsubscribe, mail: commits-unsubscr...@lists.horde.org


[commits] [Wiki] created: Doc/Dev/HordeDb

2020-05-07 Thread Wiki Guest

guest [37.4.228.151]  Thu, 07 May 2020 08:37:11 +

Created page: https://wiki.horde.org/Doc/Dev/HordeDb

+ Horde_Db Library and Horde Database Migrations

++ Horde DB: Usage by Example

+++ Get a Connection object

+++ Selecting Values

+++ Insert

+++ Delete

+++ Getting a DB handle from inside a Horde_Core_Application context



++ Migrations: Usage by Example

Migrations are PHP Class files in the /migration/ sub folder of an app  
or library. They can be run via the horde-db-migrate script or the web  
UI.

They allow schema and data conversions forward and back.

Schema files prepend the lowercased class name with a version:

The first version's file would be 1_$app_foo (usually  
1_$app_base_tables) which would contain the class named $AppFoo  
($AppBaseTables) derived from Horde_Db_Migration_Base. See  
https://github.com/horde/skeleton/blob/master/migration/1_skeleton_base_tables.php for a complete  
example.


These classes usually contain an up() and down() method to implement  
upgrades or downgrades to the next/previous schema.


Errors during Schema upgrades need to be handled by the implementer  
himself. There is no implicit rollback of schema upgrades which fail  
halfway through the up() method unless you implement an appropriate  
try/catch block yourself.


+++ Adding a new table
+++ Removing a table


+++ Adding a new column to an existing table
+++ Dropping a column from an existing table


+++ Adding an index


+++ Adding a unique key / unique index

+++ Converting for Non-Horde or Pre-H4 schemas

Check for all table's existence before adding them


+++ Manipulating data while changing fields



--
commits mailing list
Frequently Asked Questions: http://wiki.horde.org/FAQ
To unsubscribe, mail: commits-unsubscr...@lists.horde.org