Utilities
The Database Utility Class contains methods that help you manage your database.
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>
当前内容版权归 codeigniter4 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 codeigniter4 .