results.html 81 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231
  1. <!DOCTYPE html>
  2. <!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
  3. <!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
  4. <head>
  5. <meta charset="utf-8">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <title>Generating Query Results &mdash; CodeIgniter 3.1.11 documentation</title>
  8. <link rel="shortcut icon" href="../_static/ci-icon.ico"/>
  9. <link href='https://fonts.googleapis.com/css?family=Lato:400,700,400italic,700italic|Roboto+Slab:400,700|Inconsolata:400,700&subset=latin,cyrillic' rel='stylesheet' type='text/css'>
  10. <link rel="stylesheet" href="../_static/css/citheme.css" type="text/css" />
  11. <link rel="index" title="Index"
  12. href="../genindex.html"/>
  13. <link rel="search" title="Search" href="../search.html"/>
  14. <link rel="top" title="CodeIgniter 3.1.11 documentation" href="../index.html"/>
  15. <link rel="up" title="Database Reference" href="index.html"/>
  16. <link rel="next" title="Query Helper Methods" href="helpers.html"/>
  17. <link rel="prev" title="Queries" href="queries.html"/>
  18. <script src="https://cdnjs.cloudflare.com/ajax/libs/modernizr/2.6.2/modernizr.min.js"></script>
  19. </head>
  20. <body class="wy-body-for-nav" role="document">
  21. <div id="nav">
  22. <div id="nav_inner">
  23. <div id="pulldown-menu" class="ciNav">
  24. <ul>
  25. <li class="toctree-l1"><a class="reference internal" href="../general/welcome.html">Welcome to CodeIgniter</a></li>
  26. </ul>
  27. <ul>
  28. <li class="toctree-l1"><a class="reference internal" href="../installation/index.html">Installation Instructions</a><ul>
  29. <li class="toctree-l2"><a class="reference internal" href="../installation/downloads.html">Downloading CodeIgniter</a></li>
  30. <li class="toctree-l2"><a class="reference internal" href="../installation/index.html">Installation Instructions</a></li>
  31. <li class="toctree-l2"><a class="reference internal" href="../installation/upgrading.html">Upgrading From a Previous Version</a></li>
  32. <li class="toctree-l2"><a class="reference internal" href="../installation/troubleshooting.html">Troubleshooting</a></li>
  33. </ul>
  34. </li>
  35. </ul>
  36. <ul>
  37. <li class="toctree-l1"><a class="reference internal" href="../overview/index.html">CodeIgniter Overview</a><ul>
  38. <li class="toctree-l2"><a class="reference internal" href="../overview/getting_started.html">Getting Started</a></li>
  39. <li class="toctree-l2"><a class="reference internal" href="../overview/at_a_glance.html">CodeIgniter at a Glance</a></li>
  40. <li class="toctree-l2"><a class="reference internal" href="../overview/features.html">Supported Features</a></li>
  41. <li class="toctree-l2"><a class="reference internal" href="../overview/appflow.html">Application Flow Chart</a></li>
  42. <li class="toctree-l2"><a class="reference internal" href="../overview/mvc.html">Model-View-Controller</a></li>
  43. <li class="toctree-l2"><a class="reference internal" href="../overview/goals.html">Architectural Goals</a></li>
  44. </ul>
  45. </li>
  46. </ul>
  47. <ul>
  48. <li class="toctree-l1"><a class="reference internal" href="../tutorial/index.html">Tutorial</a><ul>
  49. <li class="toctree-l2"><a class="reference internal" href="../tutorial/static_pages.html">Static pages</a></li>
  50. <li class="toctree-l2"><a class="reference internal" href="../tutorial/news_section.html">News section</a></li>
  51. <li class="toctree-l2"><a class="reference internal" href="../tutorial/create_news_items.html">Create news items</a></li>
  52. <li class="toctree-l2"><a class="reference internal" href="../tutorial/conclusion.html">Conclusion</a></li>
  53. </ul>
  54. </li>
  55. </ul>
  56. <ul>
  57. <li class="toctree-l1"><a class="reference internal" href="../contributing/index.html">Contributing to CodeIgniter</a><ul>
  58. <li class="toctree-l2"><a class="reference internal" href="../documentation/index.html">Writing CodeIgniter Documentation</a></li>
  59. <li class="toctree-l2"><a class="reference internal" href="../DCO.html">Developer’s Certificate of Origin 1.1</a></li>
  60. </ul>
  61. </li>
  62. </ul>
  63. <ul>
  64. <li class="toctree-l1"><a class="reference internal" href="../general/index.html">General Topics</a><ul>
  65. <li class="toctree-l2"><a class="reference internal" href="../general/urls.html">CodeIgniter URLs</a></li>
  66. <li class="toctree-l2"><a class="reference internal" href="../general/controllers.html">Controllers</a></li>
  67. <li class="toctree-l2"><a class="reference internal" href="../general/reserved_names.html">Reserved Names</a></li>
  68. <li class="toctree-l2"><a class="reference internal" href="../general/views.html">Views</a></li>
  69. <li class="toctree-l2"><a class="reference internal" href="../general/models.html">Models</a></li>
  70. <li class="toctree-l2"><a class="reference internal" href="../general/helpers.html">Helpers</a></li>
  71. <li class="toctree-l2"><a class="reference internal" href="../general/libraries.html">Using CodeIgniter Libraries</a></li>
  72. <li class="toctree-l2"><a class="reference internal" href="../general/creating_libraries.html">Creating Libraries</a></li>
  73. <li class="toctree-l2"><a class="reference internal" href="../general/drivers.html">Using CodeIgniter Drivers</a></li>
  74. <li class="toctree-l2"><a class="reference internal" href="../general/creating_drivers.html">Creating Drivers</a></li>
  75. <li class="toctree-l2"><a class="reference internal" href="../general/core_classes.html">Creating Core System Classes</a></li>
  76. <li class="toctree-l2"><a class="reference internal" href="../general/ancillary_classes.html">Creating Ancillary Classes</a></li>
  77. <li class="toctree-l2"><a class="reference internal" href="../general/hooks.html">Hooks - Extending the Framework Core</a></li>
  78. <li class="toctree-l2"><a class="reference internal" href="../general/autoloader.html">Auto-loading Resources</a></li>
  79. <li class="toctree-l2"><a class="reference internal" href="../general/common_functions.html">Common Functions</a></li>
  80. <li class="toctree-l2"><a class="reference internal" href="../general/compatibility_functions.html">Compatibility Functions</a></li>
  81. <li class="toctree-l2"><a class="reference internal" href="../general/routing.html">URI Routing</a></li>
  82. <li class="toctree-l2"><a class="reference internal" href="../general/errors.html">Error Handling</a></li>
  83. <li class="toctree-l2"><a class="reference internal" href="../general/caching.html">Caching</a></li>
  84. <li class="toctree-l2"><a class="reference internal" href="../general/profiling.html">Profiling Your Application</a></li>
  85. <li class="toctree-l2"><a class="reference internal" href="../general/cli.html">Running via the CLI</a></li>
  86. <li class="toctree-l2"><a class="reference internal" href="../general/managing_apps.html">Managing your Applications</a></li>
  87. <li class="toctree-l2"><a class="reference internal" href="../general/environments.html">Handling Multiple Environments</a></li>
  88. <li class="toctree-l2"><a class="reference internal" href="../general/alternative_php.html">Alternate PHP Syntax for View Files</a></li>
  89. <li class="toctree-l2"><a class="reference internal" href="../general/security.html">Security</a></li>
  90. <li class="toctree-l2"><a class="reference internal" href="../general/styleguide.html">PHP Style Guide</a></li>
  91. </ul>
  92. </li>
  93. </ul>
  94. <ul>
  95. <li class="toctree-l1"><a class="reference internal" href="../libraries/index.html">Libraries</a><ul>
  96. <li class="toctree-l2"><a class="reference internal" href="../libraries/benchmark.html">Benchmarking Class</a></li>
  97. <li class="toctree-l2"><a class="reference internal" href="../libraries/caching.html">Caching Driver</a></li>
  98. <li class="toctree-l2"><a class="reference internal" href="../libraries/calendar.html">Calendaring Class</a></li>
  99. <li class="toctree-l2"><a class="reference internal" href="../libraries/cart.html">Shopping Cart Class</a></li>
  100. <li class="toctree-l2"><a class="reference internal" href="../libraries/config.html">Config Class</a></li>
  101. <li class="toctree-l2"><a class="reference internal" href="../libraries/email.html">Email Class</a></li>
  102. <li class="toctree-l2"><a class="reference internal" href="../libraries/encrypt.html">Encrypt Class</a></li>
  103. <li class="toctree-l2"><a class="reference internal" href="../libraries/encryption.html">Encryption Library</a></li>
  104. <li class="toctree-l2"><a class="reference internal" href="../libraries/file_uploading.html">File Uploading Class</a></li>
  105. <li class="toctree-l2"><a class="reference internal" href="../libraries/form_validation.html">Form Validation</a></li>
  106. <li class="toctree-l2"><a class="reference internal" href="../libraries/ftp.html">FTP Class</a></li>
  107. <li class="toctree-l2"><a class="reference internal" href="../libraries/image_lib.html">Image Manipulation Class</a></li>
  108. <li class="toctree-l2"><a class="reference internal" href="../libraries/input.html">Input Class</a></li>
  109. <li class="toctree-l2"><a class="reference internal" href="../libraries/javascript.html">Javascript Class</a></li>
  110. <li class="toctree-l2"><a class="reference internal" href="../libraries/language.html">Language Class</a></li>
  111. <li class="toctree-l2"><a class="reference internal" href="../libraries/loader.html">Loader Class</a></li>
  112. <li class="toctree-l2"><a class="reference internal" href="../libraries/migration.html">Migrations Class</a></li>
  113. <li class="toctree-l2"><a class="reference internal" href="../libraries/output.html">Output Class</a></li>
  114. <li class="toctree-l2"><a class="reference internal" href="../libraries/pagination.html">Pagination Class</a></li>
  115. <li class="toctree-l2"><a class="reference internal" href="../libraries/parser.html">Template Parser Class</a></li>
  116. <li class="toctree-l2"><a class="reference internal" href="../libraries/security.html">Security Class</a></li>
  117. <li class="toctree-l2"><a class="reference internal" href="../libraries/sessions.html">Session Library</a></li>
  118. <li class="toctree-l2"><a class="reference internal" href="../libraries/table.html">HTML Table Class</a></li>
  119. <li class="toctree-l2"><a class="reference internal" href="../libraries/trackback.html">Trackback Class</a></li>
  120. <li class="toctree-l2"><a class="reference internal" href="../libraries/typography.html">Typography Class</a></li>
  121. <li class="toctree-l2"><a class="reference internal" href="../libraries/unit_testing.html">Unit Testing Class</a></li>
  122. <li class="toctree-l2"><a class="reference internal" href="../libraries/uri.html">URI Class</a></li>
  123. <li class="toctree-l2"><a class="reference internal" href="../libraries/user_agent.html">User Agent Class</a></li>
  124. <li class="toctree-l2"><a class="reference internal" href="../libraries/xmlrpc.html">XML-RPC and XML-RPC Server Classes</a></li>
  125. <li class="toctree-l2"><a class="reference internal" href="../libraries/zip.html">Zip Encoding Class</a></li>
  126. </ul>
  127. </li>
  128. </ul>
  129. <ul class="current">
  130. <li class="toctree-l1 current"><a class="reference internal" href="index.html">Database Reference</a><ul class="current">
  131. <li class="toctree-l2"><a class="reference internal" href="examples.html">Quick Start: Usage Examples</a></li>
  132. <li class="toctree-l2"><a class="reference internal" href="configuration.html">Database Configuration</a></li>
  133. <li class="toctree-l2"><a class="reference internal" href="connecting.html">Connecting to a Database</a></li>
  134. <li class="toctree-l2"><a class="reference internal" href="queries.html">Running Queries</a></li>
  135. <li class="toctree-l2 current"><a class="current reference internal" href="#">Generating Query Results</a></li>
  136. <li class="toctree-l2"><a class="reference internal" href="helpers.html">Query Helper Functions</a></li>
  137. <li class="toctree-l2"><a class="reference internal" href="query_builder.html">Query Builder Class</a></li>
  138. <li class="toctree-l2"><a class="reference internal" href="transactions.html">Transactions</a></li>
  139. <li class="toctree-l2"><a class="reference internal" href="metadata.html">Getting MetaData</a></li>
  140. <li class="toctree-l2"><a class="reference internal" href="call_function.html">Custom Function Calls</a></li>
  141. <li class="toctree-l2"><a class="reference internal" href="caching.html">Query Caching</a></li>
  142. <li class="toctree-l2"><a class="reference internal" href="forge.html">Database Manipulation with Database Forge</a></li>
  143. <li class="toctree-l2"><a class="reference internal" href="utilities.html">Database Utilities Class</a></li>
  144. <li class="toctree-l2"><a class="reference internal" href="db_driver_reference.html">Database Driver Reference</a></li>
  145. </ul>
  146. </li>
  147. </ul>
  148. <ul>
  149. <li class="toctree-l1"><a class="reference internal" href="../helpers/index.html">Helpers</a><ul>
  150. <li class="toctree-l2"><a class="reference internal" href="../helpers/array_helper.html">Array Helper</a></li>
  151. <li class="toctree-l2"><a class="reference internal" href="../helpers/captcha_helper.html">CAPTCHA Helper</a></li>
  152. <li class="toctree-l2"><a class="reference internal" href="../helpers/cookie_helper.html">Cookie Helper</a></li>
  153. <li class="toctree-l2"><a class="reference internal" href="../helpers/date_helper.html">Date Helper</a></li>
  154. <li class="toctree-l2"><a class="reference internal" href="../helpers/directory_helper.html">Directory Helper</a></li>
  155. <li class="toctree-l2"><a class="reference internal" href="../helpers/download_helper.html">Download Helper</a></li>
  156. <li class="toctree-l2"><a class="reference internal" href="../helpers/email_helper.html">Email Helper</a></li>
  157. <li class="toctree-l2"><a class="reference internal" href="../helpers/file_helper.html">File Helper</a></li>
  158. <li class="toctree-l2"><a class="reference internal" href="../helpers/form_helper.html">Form Helper</a></li>
  159. <li class="toctree-l2"><a class="reference internal" href="../helpers/html_helper.html">HTML Helper</a></li>
  160. <li class="toctree-l2"><a class="reference internal" href="../helpers/inflector_helper.html">Inflector Helper</a></li>
  161. <li class="toctree-l2"><a class="reference internal" href="../helpers/language_helper.html">Language Helper</a></li>
  162. <li class="toctree-l2"><a class="reference internal" href="../helpers/number_helper.html">Number Helper</a></li>
  163. <li class="toctree-l2"><a class="reference internal" href="../helpers/path_helper.html">Path Helper</a></li>
  164. <li class="toctree-l2"><a class="reference internal" href="../helpers/security_helper.html">Security Helper</a></li>
  165. <li class="toctree-l2"><a class="reference internal" href="../helpers/smiley_helper.html">Smiley Helper</a></li>
  166. <li class="toctree-l2"><a class="reference internal" href="../helpers/string_helper.html">String Helper</a></li>
  167. <li class="toctree-l2"><a class="reference internal" href="../helpers/text_helper.html">Text Helper</a></li>
  168. <li class="toctree-l2"><a class="reference internal" href="../helpers/typography_helper.html">Typography Helper</a></li>
  169. <li class="toctree-l2"><a class="reference internal" href="../helpers/url_helper.html">URL Helper</a></li>
  170. <li class="toctree-l2"><a class="reference internal" href="../helpers/xml_helper.html">XML Helper</a></li>
  171. </ul>
  172. </li>
  173. </ul>
  174. </div>
  175. </div>
  176. </div>
  177. <div id="nav2">
  178. <a href="#" id="openToc">
  179. <img src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAgAAZABkAAD/7AARRHVja3kAAQAEAAAARgAA/+4ADkFkb2JlAGTAAAAAAf/bAIQABAMDAwMDBAMDBAYEAwQGBwUEBAUHCAYGBwYGCAoICQkJCQgKCgwMDAwMCgwMDQ0MDBERERERFBQUFBQUFBQUFAEEBQUIBwgPCgoPFA4ODhQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQU/8AAEQgAKwCaAwERAAIRAQMRAf/EAHsAAQAABwEBAAAAAAAAAAAAAAABAwQFBgcIAgkBAQAAAAAAAAAAAAAAAAAAAAAQAAEDAwICBwYEAgsAAAAAAAIBAwQAEQUSBiEHkROTVNQWGDFBUVIUCHEiMtOUFWGBobHRQlMkZIRVEQEAAAAAAAAAAAAAAAAAAAAA/9oADAMBAAIRAxEAPwDSC+ygkOOaUoKigUCgUCgUCgUCgUCgUCgUCgkuGguIP9FBMFb0Hqg7We+3jlmIqqYFf4ub+/QYlnOR/LqIBKGFUbf8qWv971BytQXXE7Y3Lnm3HsFhp2TaZJAdchRXpIgSpdEJWxJEW3xoKV7F5OMy7JkQn2o7D6w33XGjEAkoiqrJEqIiOIiKuhePCgqp22dyYyS3CyWHnQ5joG61HkRnmnTbaFSMhExRVQRRVJU9iUHjE7ez+fJ0MFipmUNhBV8YUd2SoIV9KkjQla9ltegttBdPLW4/qocL+UTfrMiHW4+P9M71shuyrqaHTcxsl7jegpsji8nh5ZwMvDfgTm0RTjSmjYdFCS6KoOIipdFunCgmNYTMv457MMY6U7iI6oMieDDhRm1VbIhuoOkbqtuK0Hpzb+eZcYZexUxt6UyUqK2cd0SdjtgrhOgijcgERUlJOCIl6CpgbP3blRI8XgMjNARAyKNDfeRBdFDBVUAXgQrqH4pxoJTu2NysY97LP4ac1io5q1InHFeGO24LnVKJuKOkSQ/yKir+rh7aCLG1dzypZQI2FnvTgccYOM3FeN0XWERXAUEFVQgQkUktdLpegm+Td3/Xli/L+S/mYNJIOF9G/wBeLKrZHFb0akG6W1WtQWSg3Dyg5e7V3fipE3O4/wCrktyzYA+ufas2LbZIlmnAT2kvuoN1wft95augilglX/tzP3qCu9O3LL/wV/i5v79BvmTADq14UGu91467Z6U9y0HzH/ncj/U/sT/CgynZG7I2NezpZGUjIycJkYkZSG+uQ81pbBNKLxJfjwoMqZ3/ALYHl35AJ7/cuwHcu5k7r1Q5pHetBjquqVVJWGxj9Zrtcl/Ggy3dHMvauR3HFZj5nHNxSyW5JISYDMoIwx8tFIGHZhPNaykGapr6rUAiicEoMG21lMRj8buPAz8xhJrr7uOeiPTCyAwXUaGR1mgozbTusOsFLEiJ7fbQa/h7gcjy2H3V6xppwDNtUSxCJIqp7valBuWVzJ22xuCROXNNZiJkMtms0DbjUkAZjzoDrTMd9dDRI44ZC2YsrYdKWP2WDT2S3N9dNdlRYrGMYc06IURXSYb0igrpWS485xVNS6nF4rwslkoMwnbpgZLB7bmt5uMweAhDEl4B5uSLzzqTnnyVpW2jaJHRMSIjdDiiotvy3DOE5rYTEbkl5yFn28k7JyG4c7AU2HtLH1uKfaiMPI40CdYbpNtmLdwTSn5rewLNld+7TLdeal4WarWBkbVKBjgdElMJJwAAY5fl4kB3b1fp4XvagsGS3FjJfLzDNtS8aeXx7LzT7TyzByQE5PccRGRC0ZRUDRV6y62vbjagzLmJzS2vuPK43JY6aP1TW6Jz+RIWyFtyC06y3EkiiinAo7YCqfq1AqqnGgsOH3lhZO8d1pmcpB8j5XIm9OYlBJSQ/FSS4427DKO0RC8AlcEMhFdViRR1WDWR5t3WXVuL1d106kG9vdeye2g60+1FDyW0shIcXVpyroXt8I8dfd+NB1vioAdWnD3UF1+gD4UFc6CEKpagxXN43rwJLUHz7yX2c8zokt9uHlsPIhA4aRnnHJTLptIS6CNsY7iASpxUUMkReGpfbQW0vtN5pitvrsN28rwtBD0nc0+/Yft5XhaB6TuaXfsP28rwtA9J3NPv2H7eV4Wgek7mn37D9vK8LQPSdzT79h+3leFoHpO5pd+w/byvC0D0nc0u/Yft5XhaB6TuaXfsP28rwtA9J3NLv2H7eV4Wgek7ml37D9vK8LQPSdzS79h+3leFoHpO5p9+w/byvC0E9r7Reazy2HIYVPxkS/CUHVn26cosxyv2g7h89LYmZSXOenvLEQ1YaQ222RATcQCP8rSGqqA8S02W2pQ6FhMoAIlqCtsnwoCpdKClejI4i3Sgtb+GBxVuNBSFt1pV/RQefLjPyUDy4z8lA8uM/JQPLjPyUDy4z8lA8uM/JQPLjPyUDy4z8lA8uM/JQPLjPyUDy4z8lA8utJ/koJ7WCbBU/LQXOPAFq1koK8B0pag90CggtBBf6qB0UDooHRQOigdFA6KB0UDooHRQOigdFA6KB0UDooI0EaBQf//Z" title="Toggle Table of Contents" alt="Toggle Table of Contents" />
  180. </a>
  181. </div>
  182. <div class="wy-grid-for-nav">
  183. <nav data-toggle="wy-nav-shift" class="wy-nav-side">
  184. <div class="wy-side-nav-search">
  185. <a href="../index.html" class="fa fa-home"> CodeIgniter</a>
  186. <div role="search">
  187. <form id="rtd-search-form" class="wy-form" action="../search.html" method="get">
  188. <input type="text" name="q" placeholder="Search docs" />
  189. <input type="hidden" name="check_keywords" value="yes" />
  190. <input type="hidden" name="area" value="default" />
  191. </form>
  192. </div>
  193. </div>
  194. <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
  195. <ul>
  196. <li class="toctree-l1"><a class="reference internal" href="../general/welcome.html">Welcome to CodeIgniter</a></li>
  197. </ul>
  198. <ul>
  199. <li class="toctree-l1"><a class="reference internal" href="../installation/index.html">Installation Instructions</a><ul>
  200. <li class="toctree-l2"><a class="reference internal" href="../installation/downloads.html">Downloading CodeIgniter</a></li>
  201. <li class="toctree-l2"><a class="reference internal" href="../installation/index.html">Installation Instructions</a></li>
  202. <li class="toctree-l2"><a class="reference internal" href="../installation/upgrading.html">Upgrading From a Previous Version</a></li>
  203. <li class="toctree-l2"><a class="reference internal" href="../installation/troubleshooting.html">Troubleshooting</a></li>
  204. </ul>
  205. </li>
  206. </ul>
  207. <ul>
  208. <li class="toctree-l1"><a class="reference internal" href="../overview/index.html">CodeIgniter Overview</a><ul>
  209. <li class="toctree-l2"><a class="reference internal" href="../overview/getting_started.html">Getting Started</a></li>
  210. <li class="toctree-l2"><a class="reference internal" href="../overview/at_a_glance.html">CodeIgniter at a Glance</a></li>
  211. <li class="toctree-l2"><a class="reference internal" href="../overview/features.html">Supported Features</a></li>
  212. <li class="toctree-l2"><a class="reference internal" href="../overview/appflow.html">Application Flow Chart</a></li>
  213. <li class="toctree-l2"><a class="reference internal" href="../overview/mvc.html">Model-View-Controller</a></li>
  214. <li class="toctree-l2"><a class="reference internal" href="../overview/goals.html">Architectural Goals</a></li>
  215. </ul>
  216. </li>
  217. </ul>
  218. <ul>
  219. <li class="toctree-l1"><a class="reference internal" href="../tutorial/index.html">Tutorial</a><ul>
  220. <li class="toctree-l2"><a class="reference internal" href="../tutorial/static_pages.html">Static pages</a></li>
  221. <li class="toctree-l2"><a class="reference internal" href="../tutorial/news_section.html">News section</a></li>
  222. <li class="toctree-l2"><a class="reference internal" href="../tutorial/create_news_items.html">Create news items</a></li>
  223. <li class="toctree-l2"><a class="reference internal" href="../tutorial/conclusion.html">Conclusion</a></li>
  224. </ul>
  225. </li>
  226. </ul>
  227. <ul>
  228. <li class="toctree-l1"><a class="reference internal" href="../contributing/index.html">Contributing to CodeIgniter</a><ul>
  229. <li class="toctree-l2"><a class="reference internal" href="../documentation/index.html">Writing CodeIgniter Documentation</a></li>
  230. <li class="toctree-l2"><a class="reference internal" href="../DCO.html">Developer’s Certificate of Origin 1.1</a></li>
  231. </ul>
  232. </li>
  233. </ul>
  234. <ul>
  235. <li class="toctree-l1"><a class="reference internal" href="../general/index.html">General Topics</a><ul>
  236. <li class="toctree-l2"><a class="reference internal" href="../general/urls.html">CodeIgniter URLs</a></li>
  237. <li class="toctree-l2"><a class="reference internal" href="../general/controllers.html">Controllers</a></li>
  238. <li class="toctree-l2"><a class="reference internal" href="../general/reserved_names.html">Reserved Names</a></li>
  239. <li class="toctree-l2"><a class="reference internal" href="../general/views.html">Views</a></li>
  240. <li class="toctree-l2"><a class="reference internal" href="../general/models.html">Models</a></li>
  241. <li class="toctree-l2"><a class="reference internal" href="../general/helpers.html">Helpers</a></li>
  242. <li class="toctree-l2"><a class="reference internal" href="../general/libraries.html">Using CodeIgniter Libraries</a></li>
  243. <li class="toctree-l2"><a class="reference internal" href="../general/creating_libraries.html">Creating Libraries</a></li>
  244. <li class="toctree-l2"><a class="reference internal" href="../general/drivers.html">Using CodeIgniter Drivers</a></li>
  245. <li class="toctree-l2"><a class="reference internal" href="../general/creating_drivers.html">Creating Drivers</a></li>
  246. <li class="toctree-l2"><a class="reference internal" href="../general/core_classes.html">Creating Core System Classes</a></li>
  247. <li class="toctree-l2"><a class="reference internal" href="../general/ancillary_classes.html">Creating Ancillary Classes</a></li>
  248. <li class="toctree-l2"><a class="reference internal" href="../general/hooks.html">Hooks - Extending the Framework Core</a></li>
  249. <li class="toctree-l2"><a class="reference internal" href="../general/autoloader.html">Auto-loading Resources</a></li>
  250. <li class="toctree-l2"><a class="reference internal" href="../general/common_functions.html">Common Functions</a></li>
  251. <li class="toctree-l2"><a class="reference internal" href="../general/compatibility_functions.html">Compatibility Functions</a></li>
  252. <li class="toctree-l2"><a class="reference internal" href="../general/routing.html">URI Routing</a></li>
  253. <li class="toctree-l2"><a class="reference internal" href="../general/errors.html">Error Handling</a></li>
  254. <li class="toctree-l2"><a class="reference internal" href="../general/caching.html">Caching</a></li>
  255. <li class="toctree-l2"><a class="reference internal" href="../general/profiling.html">Profiling Your Application</a></li>
  256. <li class="toctree-l2"><a class="reference internal" href="../general/cli.html">Running via the CLI</a></li>
  257. <li class="toctree-l2"><a class="reference internal" href="../general/managing_apps.html">Managing your Applications</a></li>
  258. <li class="toctree-l2"><a class="reference internal" href="../general/environments.html">Handling Multiple Environments</a></li>
  259. <li class="toctree-l2"><a class="reference internal" href="../general/alternative_php.html">Alternate PHP Syntax for View Files</a></li>
  260. <li class="toctree-l2"><a class="reference internal" href="../general/security.html">Security</a></li>
  261. <li class="toctree-l2"><a class="reference internal" href="../general/styleguide.html">PHP Style Guide</a></li>
  262. </ul>
  263. </li>
  264. </ul>
  265. <ul>
  266. <li class="toctree-l1"><a class="reference internal" href="../libraries/index.html">Libraries</a><ul>
  267. <li class="toctree-l2"><a class="reference internal" href="../libraries/benchmark.html">Benchmarking Class</a></li>
  268. <li class="toctree-l2"><a class="reference internal" href="../libraries/caching.html">Caching Driver</a></li>
  269. <li class="toctree-l2"><a class="reference internal" href="../libraries/calendar.html">Calendaring Class</a></li>
  270. <li class="toctree-l2"><a class="reference internal" href="../libraries/cart.html">Shopping Cart Class</a></li>
  271. <li class="toctree-l2"><a class="reference internal" href="../libraries/config.html">Config Class</a></li>
  272. <li class="toctree-l2"><a class="reference internal" href="../libraries/email.html">Email Class</a></li>
  273. <li class="toctree-l2"><a class="reference internal" href="../libraries/encrypt.html">Encrypt Class</a></li>
  274. <li class="toctree-l2"><a class="reference internal" href="../libraries/encryption.html">Encryption Library</a></li>
  275. <li class="toctree-l2"><a class="reference internal" href="../libraries/file_uploading.html">File Uploading Class</a></li>
  276. <li class="toctree-l2"><a class="reference internal" href="../libraries/form_validation.html">Form Validation</a></li>
  277. <li class="toctree-l2"><a class="reference internal" href="../libraries/ftp.html">FTP Class</a></li>
  278. <li class="toctree-l2"><a class="reference internal" href="../libraries/image_lib.html">Image Manipulation Class</a></li>
  279. <li class="toctree-l2"><a class="reference internal" href="../libraries/input.html">Input Class</a></li>
  280. <li class="toctree-l2"><a class="reference internal" href="../libraries/javascript.html">Javascript Class</a></li>
  281. <li class="toctree-l2"><a class="reference internal" href="../libraries/language.html">Language Class</a></li>
  282. <li class="toctree-l2"><a class="reference internal" href="../libraries/loader.html">Loader Class</a></li>
  283. <li class="toctree-l2"><a class="reference internal" href="../libraries/migration.html">Migrations Class</a></li>
  284. <li class="toctree-l2"><a class="reference internal" href="../libraries/output.html">Output Class</a></li>
  285. <li class="toctree-l2"><a class="reference internal" href="../libraries/pagination.html">Pagination Class</a></li>
  286. <li class="toctree-l2"><a class="reference internal" href="../libraries/parser.html">Template Parser Class</a></li>
  287. <li class="toctree-l2"><a class="reference internal" href="../libraries/security.html">Security Class</a></li>
  288. <li class="toctree-l2"><a class="reference internal" href="../libraries/sessions.html">Session Library</a></li>
  289. <li class="toctree-l2"><a class="reference internal" href="../libraries/table.html">HTML Table Class</a></li>
  290. <li class="toctree-l2"><a class="reference internal" href="../libraries/trackback.html">Trackback Class</a></li>
  291. <li class="toctree-l2"><a class="reference internal" href="../libraries/typography.html">Typography Class</a></li>
  292. <li class="toctree-l2"><a class="reference internal" href="../libraries/unit_testing.html">Unit Testing Class</a></li>
  293. <li class="toctree-l2"><a class="reference internal" href="../libraries/uri.html">URI Class</a></li>
  294. <li class="toctree-l2"><a class="reference internal" href="../libraries/user_agent.html">User Agent Class</a></li>
  295. <li class="toctree-l2"><a class="reference internal" href="../libraries/xmlrpc.html">XML-RPC and XML-RPC Server Classes</a></li>
  296. <li class="toctree-l2"><a class="reference internal" href="../libraries/zip.html">Zip Encoding Class</a></li>
  297. </ul>
  298. </li>
  299. </ul>
  300. <ul class="current">
  301. <li class="toctree-l1 current"><a class="reference internal" href="index.html">Database Reference</a><ul class="current">
  302. <li class="toctree-l2"><a class="reference internal" href="examples.html">Quick Start: Usage Examples</a></li>
  303. <li class="toctree-l2"><a class="reference internal" href="configuration.html">Database Configuration</a></li>
  304. <li class="toctree-l2"><a class="reference internal" href="connecting.html">Connecting to a Database</a></li>
  305. <li class="toctree-l2"><a class="reference internal" href="queries.html">Running Queries</a></li>
  306. <li class="toctree-l2 current"><a class="current reference internal" href="#">Generating Query Results</a></li>
  307. <li class="toctree-l2"><a class="reference internal" href="helpers.html">Query Helper Functions</a></li>
  308. <li class="toctree-l2"><a class="reference internal" href="query_builder.html">Query Builder Class</a></li>
  309. <li class="toctree-l2"><a class="reference internal" href="transactions.html">Transactions</a></li>
  310. <li class="toctree-l2"><a class="reference internal" href="metadata.html">Getting MetaData</a></li>
  311. <li class="toctree-l2"><a class="reference internal" href="call_function.html">Custom Function Calls</a></li>
  312. <li class="toctree-l2"><a class="reference internal" href="caching.html">Query Caching</a></li>
  313. <li class="toctree-l2"><a class="reference internal" href="forge.html">Database Manipulation with Database Forge</a></li>
  314. <li class="toctree-l2"><a class="reference internal" href="utilities.html">Database Utilities Class</a></li>
  315. <li class="toctree-l2"><a class="reference internal" href="db_driver_reference.html">Database Driver Reference</a></li>
  316. </ul>
  317. </li>
  318. </ul>
  319. <ul>
  320. <li class="toctree-l1"><a class="reference internal" href="../helpers/index.html">Helpers</a><ul>
  321. <li class="toctree-l2"><a class="reference internal" href="../helpers/array_helper.html">Array Helper</a></li>
  322. <li class="toctree-l2"><a class="reference internal" href="../helpers/captcha_helper.html">CAPTCHA Helper</a></li>
  323. <li class="toctree-l2"><a class="reference internal" href="../helpers/cookie_helper.html">Cookie Helper</a></li>
  324. <li class="toctree-l2"><a class="reference internal" href="../helpers/date_helper.html">Date Helper</a></li>
  325. <li class="toctree-l2"><a class="reference internal" href="../helpers/directory_helper.html">Directory Helper</a></li>
  326. <li class="toctree-l2"><a class="reference internal" href="../helpers/download_helper.html">Download Helper</a></li>
  327. <li class="toctree-l2"><a class="reference internal" href="../helpers/email_helper.html">Email Helper</a></li>
  328. <li class="toctree-l2"><a class="reference internal" href="../helpers/file_helper.html">File Helper</a></li>
  329. <li class="toctree-l2"><a class="reference internal" href="../helpers/form_helper.html">Form Helper</a></li>
  330. <li class="toctree-l2"><a class="reference internal" href="../helpers/html_helper.html">HTML Helper</a></li>
  331. <li class="toctree-l2"><a class="reference internal" href="../helpers/inflector_helper.html">Inflector Helper</a></li>
  332. <li class="toctree-l2"><a class="reference internal" href="../helpers/language_helper.html">Language Helper</a></li>
  333. <li class="toctree-l2"><a class="reference internal" href="../helpers/number_helper.html">Number Helper</a></li>
  334. <li class="toctree-l2"><a class="reference internal" href="../helpers/path_helper.html">Path Helper</a></li>
  335. <li class="toctree-l2"><a class="reference internal" href="../helpers/security_helper.html">Security Helper</a></li>
  336. <li class="toctree-l2"><a class="reference internal" href="../helpers/smiley_helper.html">Smiley Helper</a></li>
  337. <li class="toctree-l2"><a class="reference internal" href="../helpers/string_helper.html">String Helper</a></li>
  338. <li class="toctree-l2"><a class="reference internal" href="../helpers/text_helper.html">Text Helper</a></li>
  339. <li class="toctree-l2"><a class="reference internal" href="../helpers/typography_helper.html">Typography Helper</a></li>
  340. <li class="toctree-l2"><a class="reference internal" href="../helpers/url_helper.html">URL Helper</a></li>
  341. <li class="toctree-l2"><a class="reference internal" href="../helpers/xml_helper.html">XML Helper</a></li>
  342. </ul>
  343. </li>
  344. </ul>
  345. </div>
  346. &nbsp;
  347. </nav>
  348. <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
  349. <nav class="wy-nav-top" role="navigation" aria-label="top navigation">
  350. <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
  351. <a href="../index.html">CodeIgniter</a>
  352. </nav>
  353. <div class="wy-nav-content">
  354. <div class="rst-content">
  355. <div role="navigation" aria-label="breadcrumbs navigation">
  356. <ul class="wy-breadcrumbs">
  357. <li><a href="../index.html">Docs</a> &raquo;</li>
  358. <li><a href="index.html">Database Reference</a> &raquo;</li>
  359. <li>Generating Query Results</li>
  360. <li class="wy-breadcrumbs-aside">
  361. </li>
  362. <div style="float:right;margin-left:5px;" id="closeMe">
  363. <img title="Classic Layout" alt="classic layout" src="data:image/gif;base64,R0lGODlhFAAUAJEAAAAAADMzM////wAAACH5BAUUAAIALAAAAAAUABQAAAImlI+py+0PU5gRBRDM3DxbWoXis42X13USOLauUIqnlsaH/eY6UwAAOw==" />
  364. </div>
  365. </ul>
  366. <hr/>
  367. </div>
  368. <div role="main" class="document">
  369. <div class="section" id="generating-query-results">
  370. <h1>Generating Query Results<a class="headerlink" href="#generating-query-results" title="Permalink to this headline">¶</a></h1>
  371. <p>There are several ways to generate query results:</p>
  372. <div class="contents local topic" id="contents">
  373. <ul class="simple">
  374. <li><a class="reference internal" href="#result-arrays" id="id1">Result Arrays</a></li>
  375. <li><a class="reference internal" href="#result-rows" id="id2">Result Rows</a></li>
  376. <li><a class="reference internal" href="#custom-result-objects" id="id3">Custom Result Objects</a></li>
  377. <li><a class="reference internal" href="#result-helper-methods" id="id4">Result Helper Methods</a></li>
  378. <li><a class="reference internal" href="#class-reference" id="id5">Class Reference</a></li>
  379. </ul>
  380. </div>
  381. <div class="section" id="result-arrays">
  382. <h2><a class="toc-backref" href="#id1">Result Arrays</a><a class="headerlink" href="#result-arrays" title="Permalink to this headline">¶</a></h2>
  383. <p><strong>result()</strong></p>
  384. <p>This method returns the query result as an array of <strong>objects</strong>, or
  385. <strong>an empty array</strong> on failure. Typically you’ll use this in a foreach
  386. loop, like this:</p>
  387. <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$query</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">db</span><span class="o">-&gt;</span><span class="na">query</span><span class="p">(</span><span class="s2">&quot;YOUR QUERY&quot;</span><span class="p">);</span>
  388. <span class="k">foreach</span> <span class="p">(</span><span class="nv">$query</span><span class="o">-&gt;</span><span class="na">result</span><span class="p">()</span> <span class="k">as</span> <span class="nv">$row</span><span class="p">)</span>
  389. <span class="p">{</span>
  390. <span class="k">echo</span> <span class="nv">$row</span><span class="o">-&gt;</span><span class="na">title</span><span class="p">;</span>
  391. <span class="k">echo</span> <span class="nv">$row</span><span class="o">-&gt;</span><span class="na">name</span><span class="p">;</span>
  392. <span class="k">echo</span> <span class="nv">$row</span><span class="o">-&gt;</span><span class="na">body</span><span class="p">;</span>
  393. <span class="p">}</span>
  394. </pre></div>
  395. </div>
  396. <p>The above method is an alias of <code class="docutils literal"><span class="pre">result_object()</span></code>.</p>
  397. <p>You can also pass a string to <code class="docutils literal"><span class="pre">result()</span></code> which represents a class to
  398. instantiate for each result object (note: this class must be loaded)</p>
  399. <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$query</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">db</span><span class="o">-&gt;</span><span class="na">query</span><span class="p">(</span><span class="s2">&quot;SELECT * FROM users;&quot;</span><span class="p">);</span>
  400. <span class="k">foreach</span> <span class="p">(</span><span class="nv">$query</span><span class="o">-&gt;</span><span class="na">result</span><span class="p">(</span><span class="s1">&#39;User&#39;</span><span class="p">)</span> <span class="k">as</span> <span class="nv">$user</span><span class="p">)</span>
  401. <span class="p">{</span>
  402. <span class="k">echo</span> <span class="nv">$user</span><span class="o">-&gt;</span><span class="na">name</span><span class="p">;</span> <span class="c1">// access attributes</span>
  403. <span class="k">echo</span> <span class="nv">$user</span><span class="o">-&gt;</span><span class="na">reverse_name</span><span class="p">();</span> <span class="c1">// or methods defined on the &#39;User&#39; class</span>
  404. <span class="p">}</span>
  405. </pre></div>
  406. </div>
  407. <p><strong>result_array()</strong></p>
  408. <p>This method returns the query result as a pure array, or an empty
  409. array when no result is produced. Typically you’ll use this in a foreach
  410. loop, like this:</p>
  411. <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$query</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">db</span><span class="o">-&gt;</span><span class="na">query</span><span class="p">(</span><span class="s2">&quot;YOUR QUERY&quot;</span><span class="p">);</span>
  412. <span class="k">foreach</span> <span class="p">(</span><span class="nv">$query</span><span class="o">-&gt;</span><span class="na">result_array</span><span class="p">()</span> <span class="k">as</span> <span class="nv">$row</span><span class="p">)</span>
  413. <span class="p">{</span>
  414. <span class="k">echo</span> <span class="nv">$row</span><span class="p">[</span><span class="s1">&#39;title&#39;</span><span class="p">];</span>
  415. <span class="k">echo</span> <span class="nv">$row</span><span class="p">[</span><span class="s1">&#39;name&#39;</span><span class="p">];</span>
  416. <span class="k">echo</span> <span class="nv">$row</span><span class="p">[</span><span class="s1">&#39;body&#39;</span><span class="p">];</span>
  417. <span class="p">}</span>
  418. </pre></div>
  419. </div>
  420. </div>
  421. <div class="section" id="result-rows">
  422. <h2><a class="toc-backref" href="#id2">Result Rows</a><a class="headerlink" href="#result-rows" title="Permalink to this headline">¶</a></h2>
  423. <p><strong>row()</strong></p>
  424. <p>This method returns a single result row. If your query has more than
  425. one row, it returns only the first row. The result is returned as an
  426. <strong>object</strong>. Here’s a usage example:</p>
  427. <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$query</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">db</span><span class="o">-&gt;</span><span class="na">query</span><span class="p">(</span><span class="s2">&quot;YOUR QUERY&quot;</span><span class="p">);</span>
  428. <span class="nv">$row</span> <span class="o">=</span> <span class="nv">$query</span><span class="o">-&gt;</span><span class="na">row</span><span class="p">();</span>
  429. <span class="k">if</span> <span class="p">(</span><span class="nb">isset</span><span class="p">(</span><span class="nv">$row</span><span class="p">))</span>
  430. <span class="p">{</span>
  431. <span class="k">echo</span> <span class="nv">$row</span><span class="o">-&gt;</span><span class="na">title</span><span class="p">;</span>
  432. <span class="k">echo</span> <span class="nv">$row</span><span class="o">-&gt;</span><span class="na">name</span><span class="p">;</span>
  433. <span class="k">echo</span> <span class="nv">$row</span><span class="o">-&gt;</span><span class="na">body</span><span class="p">;</span>
  434. <span class="p">}</span>
  435. </pre></div>
  436. </div>
  437. <p>If you want a specific row returned you can submit the row number as a
  438. digit in the first parameter:</p>
  439. <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$row</span> <span class="o">=</span> <span class="nv">$query</span><span class="o">-&gt;</span><span class="na">row</span><span class="p">(</span><span class="mi">5</span><span class="p">);</span>
  440. </pre></div>
  441. </div>
  442. <p>You can also add a second String parameter, which is the name of a class
  443. to instantiate the row with:</p>
  444. <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$query</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">db</span><span class="o">-&gt;</span><span class="na">query</span><span class="p">(</span><span class="s2">&quot;SELECT * FROM users LIMIT 1;&quot;</span><span class="p">);</span>
  445. <span class="nv">$row</span> <span class="o">=</span> <span class="nv">$query</span><span class="o">-&gt;</span><span class="na">row</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="s1">&#39;User&#39;</span><span class="p">);</span>
  446. <span class="k">echo</span> <span class="nv">$row</span><span class="o">-&gt;</span><span class="na">name</span><span class="p">;</span> <span class="c1">// access attributes</span>
  447. <span class="k">echo</span> <span class="nv">$row</span><span class="o">-&gt;</span><span class="na">reverse_name</span><span class="p">();</span> <span class="c1">// or methods defined on the &#39;User&#39; class</span>
  448. </pre></div>
  449. </div>
  450. <p><strong>row_array()</strong></p>
  451. <p>Identical to the above <code class="docutils literal"><span class="pre">row()</span></code> method, except it returns an array.
  452. Example:</p>
  453. <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$query</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">db</span><span class="o">-&gt;</span><span class="na">query</span><span class="p">(</span><span class="s2">&quot;YOUR QUERY&quot;</span><span class="p">);</span>
  454. <span class="nv">$row</span> <span class="o">=</span> <span class="nv">$query</span><span class="o">-&gt;</span><span class="na">row_array</span><span class="p">();</span>
  455. <span class="k">if</span> <span class="p">(</span><span class="nb">isset</span><span class="p">(</span><span class="nv">$row</span><span class="p">))</span>
  456. <span class="p">{</span>
  457. <span class="k">echo</span> <span class="nv">$row</span><span class="p">[</span><span class="s1">&#39;title&#39;</span><span class="p">];</span>
  458. <span class="k">echo</span> <span class="nv">$row</span><span class="p">[</span><span class="s1">&#39;name&#39;</span><span class="p">];</span>
  459. <span class="k">echo</span> <span class="nv">$row</span><span class="p">[</span><span class="s1">&#39;body&#39;</span><span class="p">];</span>
  460. <span class="p">}</span>
  461. </pre></div>
  462. </div>
  463. <p>If you want a specific row returned you can submit the row number as a
  464. digit in the first parameter:</p>
  465. <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$row</span> <span class="o">=</span> <span class="nv">$query</span><span class="o">-&gt;</span><span class="na">row_array</span><span class="p">(</span><span class="mi">5</span><span class="p">);</span>
  466. </pre></div>
  467. </div>
  468. <p>In addition, you can walk forward/backwards/first/last through your
  469. results using these variations:</p>
  470. <blockquote>
  471. <div><div class="line-block">
  472. <div class="line"><strong>$row = $query-&gt;first_row()</strong></div>
  473. <div class="line"><strong>$row = $query-&gt;last_row()</strong></div>
  474. <div class="line"><strong>$row = $query-&gt;next_row()</strong></div>
  475. <div class="line"><strong>$row = $query-&gt;previous_row()</strong></div>
  476. </div>
  477. </div></blockquote>
  478. <p>By default they return an object unless you put the word “array” in the
  479. parameter:</p>
  480. <blockquote>
  481. <div><div class="line-block">
  482. <div class="line"><strong>$row = $query-&gt;first_row(‘array’)</strong></div>
  483. <div class="line"><strong>$row = $query-&gt;last_row(‘array’)</strong></div>
  484. <div class="line"><strong>$row = $query-&gt;next_row(‘array’)</strong></div>
  485. <div class="line"><strong>$row = $query-&gt;previous_row(‘array’)</strong></div>
  486. </div>
  487. </div></blockquote>
  488. <div class="admonition note">
  489. <p class="first admonition-title">Note</p>
  490. <p class="last">All the methods above will load the whole result into memory
  491. (prefetching). Use <code class="docutils literal"><span class="pre">unbuffered_row()</span></code> for processing large
  492. result sets.</p>
  493. </div>
  494. <p><strong>unbuffered_row()</strong></p>
  495. <p>This method returns a single result row without prefetching the whole
  496. result in memory as <code class="docutils literal"><span class="pre">row()</span></code> does. If your query has more than one row,
  497. it returns the current row and moves the internal data pointer ahead.</p>
  498. <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$query</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">db</span><span class="o">-&gt;</span><span class="na">query</span><span class="p">(</span><span class="s2">&quot;YOUR QUERY&quot;</span><span class="p">);</span>
  499. <span class="k">while</span> <span class="p">(</span><span class="nv">$row</span> <span class="o">=</span> <span class="nv">$query</span><span class="o">-&gt;</span><span class="na">unbuffered_row</span><span class="p">())</span>
  500. <span class="p">{</span>
  501. <span class="k">echo</span> <span class="nv">$row</span><span class="o">-&gt;</span><span class="na">title</span><span class="p">;</span>
  502. <span class="k">echo</span> <span class="nv">$row</span><span class="o">-&gt;</span><span class="na">name</span><span class="p">;</span>
  503. <span class="k">echo</span> <span class="nv">$row</span><span class="o">-&gt;</span><span class="na">body</span><span class="p">;</span>
  504. <span class="p">}</span>
  505. </pre></div>
  506. </div>
  507. <p>You can optionally pass ‘object’ (default) or ‘array’ in order to specify
  508. the returned value’s type:</p>
  509. <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$query</span><span class="o">-&gt;</span><span class="na">unbuffered_row</span><span class="p">();</span> <span class="c1">// object</span>
  510. <span class="nv">$query</span><span class="o">-&gt;</span><span class="na">unbuffered_row</span><span class="p">(</span><span class="s1">&#39;object&#39;</span><span class="p">);</span> <span class="c1">// object</span>
  511. <span class="nv">$query</span><span class="o">-&gt;</span><span class="na">unbuffered_row</span><span class="p">(</span><span class="s1">&#39;array&#39;</span><span class="p">);</span> <span class="c1">// associative array</span>
  512. </pre></div>
  513. </div>
  514. </div>
  515. <div class="section" id="custom-result-objects">
  516. <h2><a class="toc-backref" href="#id3">Custom Result Objects</a><a class="headerlink" href="#custom-result-objects" title="Permalink to this headline">¶</a></h2>
  517. <p>You can have the results returned as an instance of a custom class instead
  518. of a <code class="docutils literal"><span class="pre">stdClass</span></code> or array, as the <code class="docutils literal"><span class="pre">result()</span></code> and <code class="docutils literal"><span class="pre">result_array()</span></code>
  519. methods allow. This requires that the class is already loaded into memory.
  520. The object will have all values returned from the database set as properties.
  521. If these have been declared and are non-public then you should provide a
  522. <code class="docutils literal"><span class="pre">__set()</span></code> method to allow them to be set.</p>
  523. <p>Example:</p>
  524. <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="k">class</span> <span class="nc">User</span> <span class="p">{</span>
  525. <span class="k">public</span> <span class="nv">$id</span><span class="p">;</span>
  526. <span class="k">public</span> <span class="nv">$email</span><span class="p">;</span>
  527. <span class="k">public</span> <span class="nv">$username</span><span class="p">;</span>
  528. <span class="k">protected</span> <span class="nv">$last_login</span><span class="p">;</span>
  529. <span class="k">public</span> <span class="k">function</span> <span class="nf">last_login</span><span class="p">(</span><span class="nv">$format</span><span class="p">)</span>
  530. <span class="p">{</span>
  531. <span class="k">return</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">last_login</span><span class="o">-&gt;</span><span class="na">format</span><span class="p">(</span><span class="nv">$format</span><span class="p">);</span>
  532. <span class="p">}</span>
  533. <span class="k">public</span> <span class="k">function</span> <span class="nf">__set</span><span class="p">(</span><span class="nv">$name</span><span class="p">,</span> <span class="nv">$value</span><span class="p">)</span>
  534. <span class="p">{</span>
  535. <span class="k">if</span> <span class="p">(</span><span class="nv">$name</span> <span class="o">===</span> <span class="s1">&#39;last_login&#39;</span><span class="p">)</span>
  536. <span class="p">{</span>
  537. <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">last_login</span> <span class="o">=</span> <span class="nx">DateTime</span><span class="o">::</span><span class="na">createFromFormat</span><span class="p">(</span><span class="s1">&#39;U&#39;</span><span class="p">,</span> <span class="nv">$value</span><span class="p">);</span>
  538. <span class="p">}</span>
  539. <span class="p">}</span>
  540. <span class="k">public</span> <span class="k">function</span> <span class="nf">__get</span><span class="p">(</span><span class="nv">$name</span><span class="p">)</span>
  541. <span class="p">{</span>
  542. <span class="k">if</span> <span class="p">(</span><span class="nb">isset</span><span class="p">(</span><span class="nv">$this</span><span class="o">-&gt;</span><span class="nv">$name</span><span class="p">))</span>
  543. <span class="p">{</span>
  544. <span class="k">return</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="nv">$name</span><span class="p">;</span>
  545. <span class="p">}</span>
  546. <span class="p">}</span>
  547. <span class="p">}</span>
  548. </pre></div>
  549. </div>
  550. <p>In addition to the two methods listed below, the following methods also can
  551. take a class name to return the results as: <code class="docutils literal"><span class="pre">first_row()</span></code>, <code class="docutils literal"><span class="pre">last_row()</span></code>,
  552. <code class="docutils literal"><span class="pre">next_row()</span></code>, and <code class="docutils literal"><span class="pre">previous_row()</span></code>.</p>
  553. <p><strong>custom_result_object()</strong></p>
  554. <p>Returns the entire result set as an array of instances of the class requested.
  555. The only parameter is the name of the class to instantiate.</p>
  556. <p>Example:</p>
  557. <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$query</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">db</span><span class="o">-&gt;</span><span class="na">query</span><span class="p">(</span><span class="s2">&quot;YOUR QUERY&quot;</span><span class="p">);</span>
  558. <span class="nv">$rows</span> <span class="o">=</span> <span class="nv">$query</span><span class="o">-&gt;</span><span class="na">custom_result_object</span><span class="p">(</span><span class="s1">&#39;User&#39;</span><span class="p">);</span>
  559. <span class="k">foreach</span> <span class="p">(</span><span class="nv">$rows</span> <span class="k">as</span> <span class="nv">$row</span><span class="p">)</span>
  560. <span class="p">{</span>
  561. <span class="k">echo</span> <span class="nv">$row</span><span class="o">-&gt;</span><span class="na">id</span><span class="p">;</span>
  562. <span class="k">echo</span> <span class="nv">$row</span><span class="o">-&gt;</span><span class="na">email</span><span class="p">;</span>
  563. <span class="k">echo</span> <span class="nv">$row</span><span class="o">-&gt;</span><span class="na">last_login</span><span class="p">(</span><span class="s1">&#39;Y-m-d&#39;</span><span class="p">);</span>
  564. <span class="p">}</span>
  565. </pre></div>
  566. </div>
  567. <p><strong>custom_row_object()</strong></p>
  568. <p>Returns a single row from your query results. The first parameter is the row
  569. number of the results. The second parameter is the class name to instantiate.</p>
  570. <p>Example:</p>
  571. <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$query</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">db</span><span class="o">-&gt;</span><span class="na">query</span><span class="p">(</span><span class="s2">&quot;YOUR QUERY&quot;</span><span class="p">);</span>
  572. <span class="nv">$row</span> <span class="o">=</span> <span class="nv">$query</span><span class="o">-&gt;</span><span class="na">custom_row_object</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="s1">&#39;User&#39;</span><span class="p">);</span>
  573. <span class="k">if</span> <span class="p">(</span><span class="nb">isset</span><span class="p">(</span><span class="nv">$row</span><span class="p">))</span>
  574. <span class="p">{</span>
  575. <span class="k">echo</span> <span class="nv">$row</span><span class="o">-&gt;</span><span class="na">email</span><span class="p">;</span> <span class="c1">// access attributes</span>
  576. <span class="k">echo</span> <span class="nv">$row</span><span class="o">-&gt;</span><span class="na">last_login</span><span class="p">(</span><span class="s1">&#39;Y-m-d&#39;</span><span class="p">);</span> <span class="c1">// access class methods</span>
  577. <span class="p">}</span>
  578. </pre></div>
  579. </div>
  580. <p>You can also use the <code class="docutils literal"><span class="pre">row()</span></code> method in exactly the same way.</p>
  581. <p>Example:</p>
  582. <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$row</span> <span class="o">=</span> <span class="nv">$query</span><span class="o">-&gt;</span><span class="na">custom_row_object</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="s1">&#39;User&#39;</span><span class="p">);</span>
  583. </pre></div>
  584. </div>
  585. </div>
  586. <div class="section" id="result-helper-methods">
  587. <h2><a class="toc-backref" href="#id4">Result Helper Methods</a><a class="headerlink" href="#result-helper-methods" title="Permalink to this headline">¶</a></h2>
  588. <p><strong>num_rows()</strong></p>
  589. <p>The number of rows returned by the query. Note: In this example, $query
  590. is the variable that the query result object is assigned to:</p>
  591. <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$query</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">db</span><span class="o">-&gt;</span><span class="na">query</span><span class="p">(</span><span class="s1">&#39;SELECT * FROM my_table&#39;</span><span class="p">);</span>
  592. <span class="k">echo</span> <span class="nv">$query</span><span class="o">-&gt;</span><span class="na">num_rows</span><span class="p">();</span>
  593. </pre></div>
  594. </div>
  595. <div class="admonition note">
  596. <p class="first admonition-title">Note</p>
  597. <p class="last">Not all database drivers have a native way of getting the total
  598. number of rows for a result set. When this is the case, all of
  599. the data is prefetched and <code class="docutils literal"><span class="pre">count()</span></code> is manually called on the
  600. resulting array in order to achieve the same result.</p>
  601. </div>
  602. <p><strong>num_fields()</strong></p>
  603. <p>The number of FIELDS (columns) returned by the query. Make sure to call
  604. the method using your query result object:</p>
  605. <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$query</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">db</span><span class="o">-&gt;</span><span class="na">query</span><span class="p">(</span><span class="s1">&#39;SELECT * FROM my_table&#39;</span><span class="p">);</span>
  606. <span class="k">echo</span> <span class="nv">$query</span><span class="o">-&gt;</span><span class="na">num_fields</span><span class="p">();</span>
  607. </pre></div>
  608. </div>
  609. <p><strong>free_result()</strong></p>
  610. <p>It frees the memory associated with the result and deletes the result
  611. resource ID. Normally PHP frees its memory automatically at the end of
  612. script execution. However, if you are running a lot of queries in a
  613. particular script you might want to free the result after each query
  614. result has been generated in order to cut down on memory consumption.</p>
  615. <p>Example:</p>
  616. <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$query</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">db</span><span class="o">-&gt;</span><span class="na">query</span><span class="p">(</span><span class="s1">&#39;SELECT title FROM my_table&#39;</span><span class="p">);</span>
  617. <span class="k">foreach</span> <span class="p">(</span><span class="nv">$query</span><span class="o">-&gt;</span><span class="na">result</span><span class="p">()</span> <span class="k">as</span> <span class="nv">$row</span><span class="p">)</span>
  618. <span class="p">{</span>
  619. <span class="k">echo</span> <span class="nv">$row</span><span class="o">-&gt;</span><span class="na">title</span><span class="p">;</span>
  620. <span class="p">}</span>
  621. <span class="nv">$query</span><span class="o">-&gt;</span><span class="na">free_result</span><span class="p">();</span> <span class="c1">// The $query result object will no longer be available</span>
  622. <span class="nv">$query2</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">db</span><span class="o">-&gt;</span><span class="na">query</span><span class="p">(</span><span class="s1">&#39;SELECT name FROM some_table&#39;</span><span class="p">);</span>
  623. <span class="nv">$row</span> <span class="o">=</span> <span class="nv">$query2</span><span class="o">-&gt;</span><span class="na">row</span><span class="p">();</span>
  624. <span class="k">echo</span> <span class="nv">$row</span><span class="o">-&gt;</span><span class="na">name</span><span class="p">;</span>
  625. <span class="nv">$query2</span><span class="o">-&gt;</span><span class="na">free_result</span><span class="p">();</span> <span class="c1">// The $query2 result object will no longer be available</span>
  626. </pre></div>
  627. </div>
  628. <p><strong>data_seek()</strong></p>
  629. <p>This method sets the internal pointer for the next result row to be
  630. fetched. It is only useful in combination with <code class="docutils literal"><span class="pre">unbuffered_row()</span></code>.</p>
  631. <p>It accepts a positive integer value, which defaults to 0 and returns
  632. TRUE on success or FALSE on failure.</p>
  633. <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$query</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">db</span><span class="o">-&gt;</span><span class="na">query</span><span class="p">(</span><span class="s1">&#39;SELECT `field_name` FROM `table_name`&#39;</span><span class="p">);</span>
  634. <span class="nv">$query</span><span class="o">-&gt;</span><span class="na">data_seek</span><span class="p">(</span><span class="mi">5</span><span class="p">);</span> <span class="c1">// Skip the first 5 rows</span>
  635. <span class="nv">$row</span> <span class="o">=</span> <span class="nv">$query</span><span class="o">-&gt;</span><span class="na">unbuffered_row</span><span class="p">();</span>
  636. </pre></div>
  637. </div>
  638. <div class="admonition note">
  639. <p class="first admonition-title">Note</p>
  640. <p class="last">Not all database drivers support this feature and will return FALSE.
  641. Most notably - you won’t be able to use it with PDO.</p>
  642. </div>
  643. </div>
  644. <div class="section" id="class-reference">
  645. <h2><a class="toc-backref" href="#id5">Class Reference</a><a class="headerlink" href="#class-reference" title="Permalink to this headline">¶</a></h2>
  646. <dl class="class">
  647. <dt id="CI_DB_result">
  648. <em class="property">class </em><code class="descname">CI_DB_result</code><a class="headerlink" href="#CI_DB_result" title="Permalink to this definition">¶</a></dt>
  649. <dd><dl class="method">
  650. <dt id="CI_DB_result::result">
  651. <code class="descname">result</code><span class="sig-paren">(</span><span class="optional">[</span><em>$type = 'object'</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_DB_result::result" title="Permalink to this definition">¶</a></dt>
  652. <dd><table class="docutils field-list" frame="void" rules="none">
  653. <col class="field-name" />
  654. <col class="field-body" />
  655. <tbody valign="top">
  656. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  657. <li><strong>$type</strong> (<em>string</em>) – Type of requested results - array, object, or class name</li>
  658. </ul>
  659. </td>
  660. </tr>
  661. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">Array containing the fetched rows</p>
  662. </td>
  663. </tr>
  664. <tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">array</p>
  665. </td>
  666. </tr>
  667. </tbody>
  668. </table>
  669. <p>A wrapper for the <code class="docutils literal"><span class="pre">result_array()</span></code>, <code class="docutils literal"><span class="pre">result_object()</span></code>
  670. and <code class="docutils literal"><span class="pre">custom_result_object()</span></code> methods.</p>
  671. <p>Usage: see <a class="reference internal" href="#result-arrays">Result Arrays</a>.</p>
  672. </dd></dl>
  673. <dl class="method">
  674. <dt id="CI_DB_result::result_array">
  675. <code class="descname">result_array</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_DB_result::result_array" title="Permalink to this definition">¶</a></dt>
  676. <dd><table class="docutils field-list" frame="void" rules="none">
  677. <col class="field-name" />
  678. <col class="field-body" />
  679. <tbody valign="top">
  680. <tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">Array containing the fetched rows</td>
  681. </tr>
  682. <tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">array</td>
  683. </tr>
  684. </tbody>
  685. </table>
  686. <p>Returns the query results as an array of rows, where each
  687. row is itself an associative array.</p>
  688. <p>Usage: see <a class="reference internal" href="#result-arrays">Result Arrays</a>.</p>
  689. </dd></dl>
  690. <dl class="method">
  691. <dt id="CI_DB_result::result_object">
  692. <code class="descname">result_object</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_DB_result::result_object" title="Permalink to this definition">¶</a></dt>
  693. <dd><table class="docutils field-list" frame="void" rules="none">
  694. <col class="field-name" />
  695. <col class="field-body" />
  696. <tbody valign="top">
  697. <tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">Array containing the fetched rows</td>
  698. </tr>
  699. <tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">array</td>
  700. </tr>
  701. </tbody>
  702. </table>
  703. <p>Returns the query results as an array of rows, where each
  704. row is an object of type <code class="docutils literal"><span class="pre">stdClass</span></code>.</p>
  705. <p>Usage: see <a class="reference internal" href="#result-arrays">Result Arrays</a>.</p>
  706. </dd></dl>
  707. <dl class="method">
  708. <dt id="CI_DB_result::custom_result_object">
  709. <code class="descname">custom_result_object</code><span class="sig-paren">(</span><em>$class_name</em><span class="sig-paren">)</span><a class="headerlink" href="#CI_DB_result::custom_result_object" title="Permalink to this definition">¶</a></dt>
  710. <dd><table class="docutils field-list" frame="void" rules="none">
  711. <col class="field-name" />
  712. <col class="field-body" />
  713. <tbody valign="top">
  714. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  715. <li><strong>$class_name</strong> (<em>string</em>) – Class name for the resulting rows</li>
  716. </ul>
  717. </td>
  718. </tr>
  719. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">Array containing the fetched rows</p>
  720. </td>
  721. </tr>
  722. <tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">array</p>
  723. </td>
  724. </tr>
  725. </tbody>
  726. </table>
  727. <p>Returns the query results as an array of rows, where each
  728. row is an instance of the specified class.</p>
  729. </dd></dl>
  730. <dl class="method">
  731. <dt id="CI_DB_result::row">
  732. <code class="descname">row</code><span class="sig-paren">(</span><span class="optional">[</span><em>$n = 0</em><span class="optional">[</span>, <em>$type = 'object'</em><span class="optional">]</span><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_DB_result::row" title="Permalink to this definition">¶</a></dt>
  733. <dd><table class="docutils field-list" frame="void" rules="none">
  734. <col class="field-name" />
  735. <col class="field-body" />
  736. <tbody valign="top">
  737. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  738. <li><strong>$n</strong> (<em>int</em>) – Index of the query results row to be returned</li>
  739. <li><strong>$type</strong> (<em>string</em>) – Type of the requested result - array, object, or class name</li>
  740. </ul>
  741. </td>
  742. </tr>
  743. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">The requested row or NULL if it doesn’t exist</p>
  744. </td>
  745. </tr>
  746. <tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">mixed</p>
  747. </td>
  748. </tr>
  749. </tbody>
  750. </table>
  751. <p>A wrapper for the <code class="docutils literal"><span class="pre">row_array()</span></code>, <code class="docutils literal"><span class="pre">row_object()</span> <span class="pre">and</span>
  752. <span class="pre">``custom_row_object()</span></code> methods.</p>
  753. <p>Usage: see <a class="reference internal" href="#result-rows">Result Rows</a>.</p>
  754. </dd></dl>
  755. <dl class="method">
  756. <dt id="CI_DB_result::unbuffered_row">
  757. <code class="descname">unbuffered_row</code><span class="sig-paren">(</span><span class="optional">[</span><em>$type = 'object'</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_DB_result::unbuffered_row" title="Permalink to this definition">¶</a></dt>
  758. <dd><table class="docutils field-list" frame="void" rules="none">
  759. <col class="field-name" />
  760. <col class="field-body" />
  761. <tbody valign="top">
  762. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  763. <li><strong>$type</strong> (<em>string</em>) – Type of the requested result - array, object, or class name</li>
  764. </ul>
  765. </td>
  766. </tr>
  767. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">Next row from the result set or NULL if it doesn’t exist</p>
  768. </td>
  769. </tr>
  770. <tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">mixed</p>
  771. </td>
  772. </tr>
  773. </tbody>
  774. </table>
  775. <p>Fetches the next result row and returns it in the
  776. requested form.</p>
  777. <p>Usage: see <a class="reference internal" href="#result-rows">Result Rows</a>.</p>
  778. </dd></dl>
  779. <dl class="method">
  780. <dt id="CI_DB_result::row_array">
  781. <code class="descname">row_array</code><span class="sig-paren">(</span><span class="optional">[</span><em>$n = 0</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_DB_result::row_array" title="Permalink to this definition">¶</a></dt>
  782. <dd><table class="docutils field-list" frame="void" rules="none">
  783. <col class="field-name" />
  784. <col class="field-body" />
  785. <tbody valign="top">
  786. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  787. <li><strong>$n</strong> (<em>int</em>) – Index of the query results row to be returned</li>
  788. </ul>
  789. </td>
  790. </tr>
  791. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">The requested row or NULL if it doesn’t exist</p>
  792. </td>
  793. </tr>
  794. <tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">array</p>
  795. </td>
  796. </tr>
  797. </tbody>
  798. </table>
  799. <p>Returns the requested result row as an associative array.</p>
  800. <p>Usage: see <a class="reference internal" href="#result-rows">Result Rows</a>.</p>
  801. </dd></dl>
  802. <dl class="method">
  803. <dt id="CI_DB_result::row_object">
  804. <code class="descname">row_object</code><span class="sig-paren">(</span><span class="optional">[</span><em>$n = 0</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_DB_result::row_object" title="Permalink to this definition">¶</a></dt>
  805. <dd><table class="docutils field-list" frame="void" rules="none">
  806. <col class="field-name" />
  807. <col class="field-body" />
  808. <tbody valign="top">
  809. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  810. <li><strong>$n</strong> (<em>int</em>) – Index of the query results row to be returned</li>
  811. </ul>
  812. </td>
  813. </tr>
  814. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">The requested row or NULL if it doesn’t exist</p>
  815. </td>
  816. </tr>
  817. <tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">stdClass</p>
  818. </td>
  819. </tr>
  820. </tbody>
  821. </table>
  822. <p>Returns the requested result row as an object of type
  823. <code class="docutils literal"><span class="pre">stdClass</span></code>.</p>
  824. <p>Usage: see <a class="reference internal" href="#result-rows">Result Rows</a>.</p>
  825. </dd></dl>
  826. <dl class="method">
  827. <dt id="CI_DB_result::custom_row_object">
  828. <code class="descname">custom_row_object</code><span class="sig-paren">(</span><em>$n</em>, <em>$type</em><span class="sig-paren">)</span><a class="headerlink" href="#CI_DB_result::custom_row_object" title="Permalink to this definition">¶</a></dt>
  829. <dd><table class="docutils field-list" frame="void" rules="none">
  830. <col class="field-name" />
  831. <col class="field-body" />
  832. <tbody valign="top">
  833. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  834. <li><strong>$n</strong> (<em>int</em>) – Index of the results row to return</li>
  835. <li><strong>$class_name</strong> (<em>string</em>) – Class name for the resulting row</li>
  836. </ul>
  837. </td>
  838. </tr>
  839. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">The requested row or NULL if it doesn’t exist</p>
  840. </td>
  841. </tr>
  842. <tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">$type</p>
  843. </td>
  844. </tr>
  845. </tbody>
  846. </table>
  847. <p>Returns the requested result row as an instance of the
  848. requested class.</p>
  849. </dd></dl>
  850. <dl class="method">
  851. <dt id="CI_DB_result::data_seek">
  852. <code class="descname">data_seek</code><span class="sig-paren">(</span><span class="optional">[</span><em>$n = 0</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_DB_result::data_seek" title="Permalink to this definition">¶</a></dt>
  853. <dd><table class="docutils field-list" frame="void" rules="none">
  854. <col class="field-name" />
  855. <col class="field-body" />
  856. <tbody valign="top">
  857. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  858. <li><strong>$n</strong> (<em>int</em>) – Index of the results row to be returned next</li>
  859. </ul>
  860. </td>
  861. </tr>
  862. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">TRUE on success, FALSE on failure</p>
  863. </td>
  864. </tr>
  865. <tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">bool</p>
  866. </td>
  867. </tr>
  868. </tbody>
  869. </table>
  870. <p>Moves the internal results row pointer to the desired offset.</p>
  871. <p>Usage: see <a class="reference internal" href="#result-helper-methods">Result Helper Methods</a>.</p>
  872. </dd></dl>
  873. <dl class="method">
  874. <dt id="CI_DB_result::set_row">
  875. <code class="descname">set_row</code><span class="sig-paren">(</span><em>$key</em><span class="optional">[</span>, <em>$value = NULL</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_DB_result::set_row" title="Permalink to this definition">¶</a></dt>
  876. <dd><table class="docutils field-list" frame="void" rules="none">
  877. <col class="field-name" />
  878. <col class="field-body" />
  879. <tbody valign="top">
  880. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  881. <li><strong>$key</strong> (<em>mixed</em>) – Column name or array of key/value pairs</li>
  882. <li><strong>$value</strong> (<em>mixed</em>) – Value to assign to the column, $key is a single field name</li>
  883. </ul>
  884. </td>
  885. </tr>
  886. <tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">void</p>
  887. </td>
  888. </tr>
  889. </tbody>
  890. </table>
  891. <p>Assigns a value to a particular column.</p>
  892. </dd></dl>
  893. <dl class="method">
  894. <dt id="CI_DB_result::next_row">
  895. <code class="descname">next_row</code><span class="sig-paren">(</span><span class="optional">[</span><em>$type = 'object'</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_DB_result::next_row" title="Permalink to this definition">¶</a></dt>
  896. <dd><table class="docutils field-list" frame="void" rules="none">
  897. <col class="field-name" />
  898. <col class="field-body" />
  899. <tbody valign="top">
  900. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  901. <li><strong>$type</strong> (<em>string</em>) – Type of the requested result - array, object, or class name</li>
  902. </ul>
  903. </td>
  904. </tr>
  905. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">Next row of result set, or NULL if it doesn’t exist</p>
  906. </td>
  907. </tr>
  908. <tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">mixed</p>
  909. </td>
  910. </tr>
  911. </tbody>
  912. </table>
  913. <p>Returns the next row from the result set.</p>
  914. </dd></dl>
  915. <dl class="method">
  916. <dt id="CI_DB_result::previous_row">
  917. <code class="descname">previous_row</code><span class="sig-paren">(</span><span class="optional">[</span><em>$type = 'object'</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_DB_result::previous_row" title="Permalink to this definition">¶</a></dt>
  918. <dd><table class="docutils field-list" frame="void" rules="none">
  919. <col class="field-name" />
  920. <col class="field-body" />
  921. <tbody valign="top">
  922. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  923. <li><strong>$type</strong> (<em>string</em>) – Type of the requested result - array, object, or class name</li>
  924. </ul>
  925. </td>
  926. </tr>
  927. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">Previous row of result set, or NULL if it doesn’t exist</p>
  928. </td>
  929. </tr>
  930. <tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">mixed</p>
  931. </td>
  932. </tr>
  933. </tbody>
  934. </table>
  935. <p>Returns the previous row from the result set.</p>
  936. </dd></dl>
  937. <dl class="method">
  938. <dt id="CI_DB_result::first_row">
  939. <code class="descname">first_row</code><span class="sig-paren">(</span><span class="optional">[</span><em>$type = 'object'</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_DB_result::first_row" title="Permalink to this definition">¶</a></dt>
  940. <dd><table class="docutils field-list" frame="void" rules="none">
  941. <col class="field-name" />
  942. <col class="field-body" />
  943. <tbody valign="top">
  944. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  945. <li><strong>$type</strong> (<em>string</em>) – Type of the requested result - array, object, or class name</li>
  946. </ul>
  947. </td>
  948. </tr>
  949. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">First row of result set, or NULL if it doesn’t exist</p>
  950. </td>
  951. </tr>
  952. <tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">mixed</p>
  953. </td>
  954. </tr>
  955. </tbody>
  956. </table>
  957. <p>Returns the first row from the result set.</p>
  958. </dd></dl>
  959. <dl class="method">
  960. <dt id="CI_DB_result::last_row">
  961. <code class="descname">last_row</code><span class="sig-paren">(</span><span class="optional">[</span><em>$type = 'object'</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_DB_result::last_row" title="Permalink to this definition">¶</a></dt>
  962. <dd><table class="docutils field-list" frame="void" rules="none">
  963. <col class="field-name" />
  964. <col class="field-body" />
  965. <tbody valign="top">
  966. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  967. <li><strong>$type</strong> (<em>string</em>) – Type of the requested result - array, object, or class name</li>
  968. </ul>
  969. </td>
  970. </tr>
  971. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">Last row of result set, or NULL if it doesn’t exist</p>
  972. </td>
  973. </tr>
  974. <tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">mixed</p>
  975. </td>
  976. </tr>
  977. </tbody>
  978. </table>
  979. <p>Returns the last row from the result set.</p>
  980. </dd></dl>
  981. <dl class="method">
  982. <dt id="CI_DB_result::num_rows">
  983. <code class="descname">num_rows</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_DB_result::num_rows" title="Permalink to this definition">¶</a></dt>
  984. <dd><table class="docutils field-list" frame="void" rules="none">
  985. <col class="field-name" />
  986. <col class="field-body" />
  987. <tbody valign="top">
  988. <tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">Number of rows in the result set</td>
  989. </tr>
  990. <tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">int</td>
  991. </tr>
  992. </tbody>
  993. </table>
  994. <p>Returns the number of rows in the result set.</p>
  995. <p>Usage: see <a class="reference internal" href="#result-helper-methods">Result Helper Methods</a>.</p>
  996. </dd></dl>
  997. <dl class="method">
  998. <dt id="CI_DB_result::num_fields">
  999. <code class="descname">num_fields</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_DB_result::num_fields" title="Permalink to this definition">¶</a></dt>
  1000. <dd><table class="docutils field-list" frame="void" rules="none">
  1001. <col class="field-name" />
  1002. <col class="field-body" />
  1003. <tbody valign="top">
  1004. <tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">Number of fields in the result set</td>
  1005. </tr>
  1006. <tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">int</td>
  1007. </tr>
  1008. </tbody>
  1009. </table>
  1010. <p>Returns the number of fields in the result set.</p>
  1011. <p>Usage: see <a class="reference internal" href="#result-helper-methods">Result Helper Methods</a>.</p>
  1012. </dd></dl>
  1013. <dl class="method">
  1014. <dt id="CI_DB_result::field_data">
  1015. <code class="descname">field_data</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_DB_result::field_data" title="Permalink to this definition">¶</a></dt>
  1016. <dd><table class="docutils field-list" frame="void" rules="none">
  1017. <col class="field-name" />
  1018. <col class="field-body" />
  1019. <tbody valign="top">
  1020. <tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">Array containing field meta-data</td>
  1021. </tr>
  1022. <tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">array</td>
  1023. </tr>
  1024. </tbody>
  1025. </table>
  1026. <p>Generates an array of <code class="docutils literal"><span class="pre">stdClass</span></code> objects containing
  1027. field meta-data.</p>
  1028. </dd></dl>
  1029. <dl class="method">
  1030. <dt id="CI_DB_result::free_result">
  1031. <code class="descname">free_result</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_DB_result::free_result" title="Permalink to this definition">¶</a></dt>
  1032. <dd><table class="docutils field-list" frame="void" rules="none">
  1033. <col class="field-name" />
  1034. <col class="field-body" />
  1035. <tbody valign="top">
  1036. <tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">void</td>
  1037. </tr>
  1038. </tbody>
  1039. </table>
  1040. <p>Frees a result set.</p>
  1041. <p>Usage: see <a class="reference internal" href="#result-helper-methods">Result Helper Methods</a>.</p>
  1042. </dd></dl>
  1043. <dl class="method">
  1044. <dt id="CI_DB_result::list_fields">
  1045. <code class="descname">list_fields</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_DB_result::list_fields" title="Permalink to this definition">¶</a></dt>
  1046. <dd><table class="docutils field-list" frame="void" rules="none">
  1047. <col class="field-name" />
  1048. <col class="field-body" />
  1049. <tbody valign="top">
  1050. <tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">Array of column names</td>
  1051. </tr>
  1052. <tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">array</td>
  1053. </tr>
  1054. </tbody>
  1055. </table>
  1056. <p>Returns an array containing the field names in the
  1057. result set.</p>
  1058. </dd></dl>
  1059. </dd></dl>
  1060. </div>
  1061. </div>
  1062. </div>
  1063. <footer>
  1064. <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
  1065. <a href="helpers.html" class="btn btn-neutral float-right" title="Query Helper Methods">Next <span class="fa fa-arrow-circle-right"></span></a>
  1066. <a href="queries.html" class="btn btn-neutral" title="Queries"><span class="fa fa-arrow-circle-left"></span> Previous</a>
  1067. </div>
  1068. <hr/>
  1069. <div role="contentinfo">
  1070. <p>
  1071. &copy; Copyright 2014 - 2019, British Columbia Institute of Technology.
  1072. Last updated on Sep 19, 2019.
  1073. </p>
  1074. </div>
  1075. Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
  1076. </footer>
  1077. </div>
  1078. </div>
  1079. </section>
  1080. </div>
  1081. <script type="text/javascript">
  1082. var DOCUMENTATION_OPTIONS = {
  1083. URL_ROOT:'../',
  1084. VERSION:'3.1.11',
  1085. COLLAPSE_INDEX:false,
  1086. FILE_SUFFIX:'.html',
  1087. HAS_SOURCE: false
  1088. };
  1089. </script>
  1090. <script type="text/javascript" src="../_static/jquery.js"></script>
  1091. <script type="text/javascript" src="../_static/underscore.js"></script>
  1092. <script type="text/javascript" src="../_static/doctools.js"></script>
  1093. <script type="text/javascript" src="../_static/js/theme.js"></script>
  1094. <script type="text/javascript">
  1095. jQuery(function () {
  1096. SphinxRtdTheme.StickyNav.enable();
  1097. });
  1098. </script>
  1099. </body>
  1100. </html>