Skip to content

Commit

Permalink
add documentation for getXMLFromResult()
Browse files Browse the repository at this point in the history
  • Loading branch information
samsonasik committed Oct 11, 2018
1 parent 29565d3 commit 58e40b5
Show file tree
Hide file tree
Showing 3 changed files with 112 additions and 0 deletions.
74 changes: 74 additions & 0 deletions system/Database/MySQLi/Utils.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<?php namespace CodeIgniter\Database\MySQLi;

/**
* CodeIgniter
*
* An open source application development framework for PHP
*
* This content is released under the MIT License (MIT)
*
* Copyright (c) 2014-2018 British Columbia Institute of Technology
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* @package CodeIgniter
* @author CodeIgniter Dev Team
* @copyright 2014-2018 British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
* @since Version 3.0.0
* @filesource
*/

/**
* Utils for Postgre
*/
class Utils extends \CodeIgniter\Database\BaseUtils
{

/**
* List databases statement
*
* @var string
*/
protected $listDatabases = 'SHOW DATABASES';

/**
* OPTIMIZE TABLE statement
*
* @var string
*/
protected $optimizeTable = 'OPTIMIZE TABLE %s';

//--------------------------------------------------------------------

/**
* Platform dependent version of the backup function.
*
* @param array|null $prefs
*
* @return mixed
*/
public function _backup(array $prefs = null)
{
throw new DatabaseException('Unsupported feature of the database platform you are using.');
}

//--------------------------------------------------------------------
}
1 change: 1 addition & 0 deletions user_guide_src/source/database/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ patterns. The database functions offer clear, simple syntax.
Getting MetaData <metadata>
Custom Function Calls <call_function>
Database Events <events>
Database Utilities <utilities>
37 changes: 37 additions & 0 deletions user_guide_src/source/database/utilities.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
########################
Utilities
########################

The Database Utility Class contains methods that help you manage your database.

.. contents::
:local:
:depth: 2

*******************
Get XML FROM Result
*******************

**getXMLFromResult()**

This method returns the xml result from database result. You can do like this::

$model = new class extends \CodeIgniter\Model {
protected $table = 'foo';
protected $primaryKey = 'id';
};
$db = \Closure::bind(function ($model) {
return $model->db;
}, null, $model)($model);

$util = (new \CodeIgniter\Database\Database())->loadUtils($db);
echo $util->getXMLFromResult($model->get());

and it will get the following xml result::

<root>
<element>
<id>1</id>
<name>bar</name>
</element>
</root>

0 comments on commit 58e40b5

Please sign in to comment.