aboutsummaryrefslogtreecommitdiff
path: root/classes/CinisisDb.php
diff options
context:
space:
mode:
authorSilvio <silvio@devlet.com.br>2010-07-27 10:52:00 -0300
committerSilvio <silvio@devlet.com.br>2010-07-27 10:52:00 -0300
commit1c7744d7b0298723bcc2783663b60cd8a2c0e67b (patch)
tree0dfe210d998392cf3c0d789b109fff93573aa73b /classes/CinisisDb.php
parent362ddf298200ee6a7dfcc535df48d22ee2478e9c (diff)
downloadcinisis-1c7744d7b0298723bcc2783663b60cd8a2c0e67b.tar.gz
cinisis-1c7744d7b0298723bcc2783663b60cd8a2c0e67b.tar.bz2
Moving join_subfields and main_field_name to CinisisDb
Diffstat (limited to 'classes/CinisisDb.php')
-rw-r--r--classes/CinisisDb.php37
1 files changed, 37 insertions, 0 deletions
diff --git a/classes/CinisisDb.php b/classes/CinisisDb.php
index 32f0a28..a016528 100644
--- a/classes/CinisisDb.php
+++ b/classes/CinisisDb.php
@@ -156,4 +156,41 @@ class CinisisDb {
return call_user_func(array(__CLASS__, 'base')) .'/'. $config;
}
+
+ /**
+ * Whether to join field and subfields in a single array.
+ *
+ * @param $format
+ * Database format.
+ *
+ * @return
+ * Boolean.
+ */
+ static function join_subfields($format) {
+ if ($format['db']['join_subfields']) {
+ return TRUE;
+ }
+
+ return FALSE;
+ }
+
+ /**
+ * Determine the main field name depending on db configuration.
+ *
+ * @param $key
+ * Field key.
+ *
+ * @param $format
+ * Database format.
+ *
+ * @return
+ * Main field name, 'field' by default.
+ */
+ static function main_field_name($format, $key) {
+ if (self::join_subfields($format)) {
+ return $format['fields'][$key]['name'];
+ }
+
+ return 'field';
+ }
}