PageRenderTime 41ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/system/database/drivers/cubrid/cubrid_result.php

https://bitbucket.org/saifshuvo/codeigniter
PHP | 170 lines | 52 code | 20 blank | 98 comment | 3 complexity | c29ffa2bff9648fc42e9a0cf65e1b923 MD5 | raw file
  1. <?php
  2. /**
  3. * CodeIgniter
  4. *
  5. * An open source application development framework for PHP 5.2.4 or newer
  6. *
  7. * NOTICE OF LICENSE
  8. *
  9. * Licensed under the Open Software License version 3.0
  10. *
  11. * This source file is subject to the Open Software License (OSL 3.0) that is
  12. * bundled with this package in the files license.txt / license.rst. It is
  13. * also available through the world wide web at this URL:
  14. * http://opensource.org/licenses/OSL-3.0
  15. * If you did not receive a copy of the license and are unable to obtain it
  16. * through the world wide web, please send an email to
  17. * licensing@ellislab.com so we can send you a copy immediately.
  18. *
  19. * @package CodeIgniter
  20. * @author EllisLab Dev Team
  21. * @copyright Copyright (c) 2008 - 2013, EllisLab, Inc. (http://ellislab.com/)
  22. * @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
  23. * @link http://codeigniter.com
  24. * @since Version 2.1
  25. * @filesource
  26. */
  27. defined('BASEPATH') OR exit('No direct script access allowed');
  28. /**
  29. * CUBRID Result Class
  30. *
  31. * This class extends the parent result class: CI_DB_result
  32. *
  33. * @category Database
  34. * @author Esen Sagynov
  35. * @link http://codeigniter.com/user_guide/database/
  36. * @since 2.1
  37. */
  38. class CI_DB_cubrid_result extends CI_DB_result {
  39. /**
  40. * Number of rows in the result set
  41. *
  42. * @return int
  43. */
  44. public function num_rows()
  45. {
  46. return is_int($this->num_rows)
  47. ? $this->num_rows
  48. : $this->num_rows = @cubrid_num_rows($this->result_id);
  49. }
  50. // --------------------------------------------------------------------
  51. /**
  52. * Number of fields in the result set
  53. *
  54. * @return int
  55. */
  56. public function num_fields()
  57. {
  58. return @cubrid_num_fields($this->result_id);
  59. }
  60. // --------------------------------------------------------------------
  61. /**
  62. * Fetch Field Names
  63. *
  64. * Generates an array of column names
  65. *
  66. * @return array
  67. */
  68. public function list_fields()
  69. {
  70. return cubrid_column_names($this->result_id);
  71. }
  72. // --------------------------------------------------------------------
  73. /**
  74. * Field data
  75. *
  76. * Generates an array of objects containing field meta-data
  77. *
  78. * @return array
  79. */
  80. public function field_data()
  81. {
  82. $retval = array();
  83. for ($i = 0, $c = $this->num_fields(); $i < $c; $i++)
  84. {
  85. $retval[$i] = new stdClass();
  86. $retval[$i]->name = cubrid_field_name($this->result_id, $i);
  87. $retval[$i]->type = cubrid_field_type($this->result_id, $i);
  88. $retval[$i]->max_length = cubrid_field_len($this->result_id, $i);
  89. $retval[$i]->primary_key = (int) (strpos(cubrid_field_flags($this->result_id, $i), 'primary_key') !== FALSE);
  90. }
  91. return $retval;
  92. }
  93. // --------------------------------------------------------------------
  94. /**
  95. * Free the result
  96. *
  97. * @return void
  98. */
  99. public function free_result()
  100. {
  101. if (is_resource($this->result_id) OR
  102. (get_resource_type($this->result_id) === 'Unknown' && preg_match('/Resource id #/', strval($this->result_id))))
  103. {
  104. cubrid_close_request($this->result_id);
  105. $this->result_id = FALSE;
  106. }
  107. }
  108. // --------------------------------------------------------------------
  109. /**
  110. * Data Seek
  111. *
  112. * Moves the internal pointer to the desired offset. We call
  113. * this internally before fetching results to make sure the
  114. * result set starts at zero.
  115. *
  116. * @param int $n
  117. * @return bool
  118. */
  119. public function data_seek($n = 0)
  120. {
  121. return cubrid_data_seek($this->result_id, $n);
  122. }
  123. // --------------------------------------------------------------------
  124. /**
  125. * Result - associative array
  126. *
  127. * Returns the result set as an array
  128. *
  129. * @return array
  130. */
  131. protected function _fetch_assoc()
  132. {
  133. return cubrid_fetch_assoc($this->result_id);
  134. }
  135. // --------------------------------------------------------------------
  136. /**
  137. * Result - object
  138. *
  139. * Returns the result set as an object
  140. *
  141. * @param string $class_name
  142. * @return object
  143. */
  144. protected function _fetch_object($class_name = 'stdClass')
  145. {
  146. return cubrid_fetch_object($this->result_id, $class_name);
  147. }
  148. }
  149. /* End of file cubrid_result.php */
  150. /* Location: ./system/database/drivers/cubrid/cubrid_result.php */