diff options
author | Silvio <silvio@devlet.com.br> | 2010-04-06 16:16:50 -0300 |
---|---|---|
committer | Silvio <silvio@devlet.com.br> | 2010-04-06 16:16:50 -0300 |
commit | a80a88d99cb102fad4a23d5ea5732d489e70eddf (patch) | |
tree | 8d5a4bb15b3d6d38ed8bc132dc507c56d23a1711 /classes/SchemaDb.php | |
parent | f6f1d270419bbd9696974719b15b8c01b19b032b (diff) | |
download | cinisis-a80a88d99cb102fad4a23d5ea5732d489e70eddf.tar.gz cinisis-a80a88d99cb102fad4a23d5ea5732d489e70eddf.tar.bz2 |
Enhanced config check
Diffstat (limited to 'classes/SchemaDb.php')
-rw-r--r-- | classes/SchemaDb.php | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/classes/SchemaDb.php b/classes/SchemaDb.php index 2756026..c00ae66 100644 --- a/classes/SchemaDb.php +++ b/classes/SchemaDb.php @@ -1,5 +1,9 @@ <?php +/** + * SchemaDb class with standard database procedures and + * configuration. + */ class SchemaDb { /** * Return the required database config. @@ -36,7 +40,7 @@ class SchemaDb { } /** - * Return an example schema. + * Return an example database schema. * * @see IsisDb::example() */ @@ -65,11 +69,28 @@ class SchemaDb { } /** - * Check required fields. + * Recursively check for required fields in a database schema. * - * @todo + * @see IsisDb::check() */ - function check($schema = NULL) { + function check($schema, $section = NULL) { + if ($section === NULL) { + $section = SchemaDb::required(); + } + + foreach ($section as $key => $value) { + if (!isset($schema[$key])) { + throw new Exception('Undefined required parameter '. $key .' on database configuration.'); + return FALSE; + } + + if (is_array($value)) { + if (SchemaDb::check($schema[$key], $section[$key]) == FALSE) { + return FALSE; + } + } + } + return $schema; } } |