From 31388c84a2dd77a6a6b03490085ad1d62aefa5e9 Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 30 Nov 2023 11:42:10 +0900 Subject: [PATCH 1/3] docs: fix description for getXMLFromResult() --- user_guide_src/source/database/utilities.rst | 18 +++++++++++------- .../source/database/utilities/001.php | 18 ++++++++++-------- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/user_guide_src/source/database/utilities.rst b/user_guide_src/source/database/utilities.rst index 6bbc99b28ced..43349809b194 100644 --- a/user_guide_src/source/database/utilities.rst +++ b/user_guide_src/source/database/utilities.rst @@ -8,18 +8,17 @@ The Database Utility Class contains methods that help you manage your database. :local: :depth: 2 -******************* -Get XML from Result -******************* -getXMLFromResult() -================== +Export a Query Result as an XML Document +======================================== -This method returns the xml result from database result. You can do like this: +Permits you to generate an XML file from a query result. The first +parameter expects a query result object, the second may contain an +optional array of config parameters. Example: .. literalinclude:: utilities/001.php -and it will get the following xml result:: +and it will get the following xml result when the ``mytable`` has columns ``id`` and ``name``:: @@ -27,3 +26,8 @@ and it will get the following xml result:: bar + +.. important:: This method will NOT write the XML file for you. It + simply creates the XML layout. If you need to write the file + use the :php:func:`write_file()` helper. + diff --git a/user_guide_src/source/database/utilities/001.php b/user_guide_src/source/database/utilities/001.php index 41582ffca023..6cdfacd81834 100644 --- a/user_guide_src/source/database/utilities/001.php +++ b/user_guide_src/source/database/utilities/001.php @@ -1,13 +1,15 @@ query('SELECT * FROM mytable'); -$util = \CodeIgniter\Database\Config::utils(); +$config = [ + 'root' => 'root', + 'element' => 'element', + 'newline' => "\n", + 'tab' => "\t", +]; -echo $util->getXMLFromResult($model->get()); +echo $dbutil->getXMLFromResult($query, $config); From 3e076d3706f3a84b2e2e0dd00bb7e414659f5fdf Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 30 Nov 2023 11:50:12 +0900 Subject: [PATCH 2/3] docs: add "Initializing the Utility Class" --- user_guide_src/source/database/utilities.rst | 28 ++++++++++++++++--- .../source/database/utilities/002.php | 3 ++ .../source/database/utilities/003.php | 3 ++ 3 files changed, 30 insertions(+), 4 deletions(-) create mode 100644 user_guide_src/source/database/utilities/002.php create mode 100644 user_guide_src/source/database/utilities/003.php diff --git a/user_guide_src/source/database/utilities.rst b/user_guide_src/source/database/utilities.rst index 43349809b194..8a094cfff549 100644 --- a/user_guide_src/source/database/utilities.rst +++ b/user_guide_src/source/database/utilities.rst @@ -1,6 +1,6 @@ -######### -Utilities -######### +###################### +Database Utility Class +###################### The Database Utility Class contains methods that help you manage your database. @@ -8,6 +8,27 @@ The Database Utility Class contains methods that help you manage your database. :local: :depth: 2 +****************************** +Initializing the Utility Class +****************************** + +Load the Utility Class as follows: + +.. literalinclude:: utilities/002.php + :lines: 2- + +You can also pass another database group to the DB Utility loader, in case +the database you want to manage isn't the default one: + +.. literalinclude:: utilities/003.php + :lines: 2- + +In the above example, we're passing a database group name as the first +parameter. + +**************************** +Using the Database Utilities +**************************** Export a Query Result as an XML Document ======================================== @@ -30,4 +51,3 @@ and it will get the following xml result when the ``mytable`` has columns ``id`` .. important:: This method will NOT write the XML file for you. It simply creates the XML layout. If you need to write the file use the :php:func:`write_file()` helper. - diff --git a/user_guide_src/source/database/utilities/002.php b/user_guide_src/source/database/utilities/002.php new file mode 100644 index 000000000000..895dd88fd58c --- /dev/null +++ b/user_guide_src/source/database/utilities/002.php @@ -0,0 +1,3 @@ + Date: Thu, 30 Nov 2023 16:02:45 +0900 Subject: [PATCH 3/3] docs: fix factory classname --- user_guide_src/source/database/utilities/001.php | 2 +- user_guide_src/source/database/utilities/002.php | 2 +- user_guide_src/source/database/utilities/003.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/user_guide_src/source/database/utilities/001.php b/user_guide_src/source/database/utilities/001.php index 6cdfacd81834..131222efc86b 100644 --- a/user_guide_src/source/database/utilities/001.php +++ b/user_guide_src/source/database/utilities/001.php @@ -1,7 +1,7 @@ query('SELECT * FROM mytable'); diff --git a/user_guide_src/source/database/utilities/002.php b/user_guide_src/source/database/utilities/002.php index 895dd88fd58c..42bbbd63acc6 100644 --- a/user_guide_src/source/database/utilities/002.php +++ b/user_guide_src/source/database/utilities/002.php @@ -1,3 +1,3 @@