Zend_Db_Adapter.xml 103 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!-- Reviewed: no -->
  3. <sect1 id="zend.db.adapter">
  4. <title>Zend_Db_Adapter</title>
  5. <para>
  6. <classname>Zend_Db</classname> and its related classes provide a simple
  7. <acronym>SQL</acronym> database interface for Zend Framework. The
  8. <classname>Zend_Db_Adapter</classname> is the basic class you use to connect your
  9. <acronym>PHP</acronym> application to an <acronym>RDBMS</acronym>. There is a different
  10. Adapter class for each brand of <acronym>RDBMS</acronym>.
  11. </para>
  12. <para>
  13. The <classname>Zend_Db</classname> adapters create a bridge from the vendor-specific
  14. <acronym>PHP</acronym> extensions to a common interface to help you write
  15. <acronym>PHP</acronym> applications once and deploy with multiple brands of
  16. <acronym>RDBMS</acronym> with very little effort.
  17. </para>
  18. <para>
  19. The interface of the adapter class is similar to the interface of the
  20. <ulink url="http://www.php.net/pdo">PHP Data Objects</ulink> extension.
  21. <classname>Zend_Db</classname> provides Adapter classes to <acronym>PDO</acronym> drivers
  22. for the following <acronym>RDBMS</acronym> brands:
  23. </para>
  24. <itemizedlist>
  25. <listitem>
  26. <para>
  27. <acronym>IBM</acronym> <acronym>DB2</acronym> and Informix Dynamic Server
  28. (<acronym>IDS</acronym>), using the <ulink
  29. url="http://www.php.net/pdo-ibm">pdo_ibm</ulink> <acronym>PHP</acronym>
  30. extension
  31. </para>
  32. </listitem>
  33. <listitem>
  34. <para>
  35. MariaDB, using the <ulink url="http://www.php.net/pdo-mysql">pdo_mysql</ulink>
  36. <acronym>PHP</acronym> extension
  37. </para>
  38. </listitem>
  39. <listitem>
  40. <para>
  41. MySQL, using the <ulink url="http://www.php.net/pdo-mysql">pdo_mysql</ulink>
  42. <acronym>PHP</acronym> extension
  43. </para>
  44. </listitem>
  45. <listitem>
  46. <para>
  47. Microsoft <acronym>SQL</acronym> Server, using the <ulink
  48. url="http://www.php.net/pdo-dblib">pdo_dblib</ulink> <acronym>PHP</acronym>
  49. extension
  50. </para>
  51. </listitem>
  52. <listitem>
  53. <para>
  54. Oracle, using the <ulink url="http://www.php.net/pdo-oci">pdo_oci</ulink>
  55. <acronym>PHP</acronym> extension
  56. </para>
  57. </listitem>
  58. <listitem>
  59. <para>
  60. PostgreSQL, using the <ulink url="http://www.php.net/pdo-pgsql">pdo_pgsql</ulink>
  61. <acronym>PHP</acronym> extension
  62. </para>
  63. </listitem>
  64. <listitem>
  65. <para>
  66. SQLite, using the <ulink url="http://www.php.net/pdo-sqlite">pdo_sqlite</ulink>
  67. <acronym>PHP</acronym> extension
  68. </para>
  69. </listitem>
  70. </itemizedlist>
  71. <para>
  72. In addition, <classname>Zend_Db</classname> provides Adapter classes that utilize
  73. <acronym>PHP</acronym> database extensions for the following <acronym>RDBMS</acronym>
  74. brands:
  75. </para>
  76. <itemizedlist>
  77. <listitem>
  78. <para>
  79. MariaDB, using the <ulink url="http://www.php.net/mysqli">mysqli</ulink>
  80. <acronym>PHP</acronym> extension
  81. </para>
  82. </listitem>
  83. <listitem>
  84. <para>
  85. MySQL, using the <ulink url="http://www.php.net/mysqli">mysqli</ulink>
  86. <acronym>PHP</acronym> extension
  87. </para>
  88. </listitem>
  89. <listitem>
  90. <para>
  91. Oracle, using the <ulink url="http://www.php.net/oci8">oci8</ulink>
  92. <acronym>PHP</acronym> extension
  93. </para>
  94. </listitem>
  95. <listitem>
  96. <para>
  97. <acronym>IBM</acronym> <acronym>DB2</acronym> and <acronym>DB2</acronym> I5, using
  98. the <ulink url="http://www.php.net/ibm_db2">ibm_db2</ulink> <acronym>PHP</acronym>
  99. extension
  100. </para>
  101. </listitem>
  102. <listitem>
  103. <para>
  104. Firebird (Interbase), using the <ulink
  105. url="http://www.php.net/ibase">php_interbase</ulink> <acronym>PHP</acronym>
  106. extension
  107. </para>
  108. </listitem>
  109. </itemizedlist>
  110. <note>
  111. <para>
  112. Each <classname>Zend_Db</classname> Adapter uses a <acronym>PHP</acronym> extension. You
  113. must have the respective <acronym>PHP</acronym> extension enabled in your
  114. <acronym>PHP</acronym> environment to use a <classname>Zend_Db</classname> Adapter. For
  115. example, if you use any of the <acronym>PDO</acronym> <classname>Zend_Db</classname>
  116. Adapters, you need to enable both the <acronym>PDO</acronym> extension and the
  117. <acronym>PDO</acronym> driver for the brand of <acronym>RDBMS</acronym> you use.
  118. </para>
  119. </note>
  120. <sect2 id="zend.db.adapter.connecting">
  121. <title>Connecting to a Database Using an Adapter</title>
  122. <para>
  123. This section describes how to create an instance of a database Adapter.
  124. This corresponds to making a connection to your <acronym>RDBMS</acronym> server from
  125. your <acronym>PHP</acronym> application.
  126. </para>
  127. <sect3 id="zend.db.adapter.connecting.constructor">
  128. <title>Using a Zend_Db Adapter Constructor</title>
  129. <para>
  130. You can create an instance of an adapter using its constructor.
  131. An adapter constructor takes one argument, which is an array
  132. of parameters used to declare the connection.
  133. </para>
  134. <example id="zend.db.adapter.connecting.constructor.example">
  135. <title>Using an Adapter Constructor</title>
  136. <programlisting language="php"><![CDATA[
  137. $db = new Zend_Db_Adapter_Pdo_Mysql(array(
  138. 'host' => '127.0.0.1',
  139. 'username' => 'webuser',
  140. 'password' => 'xxxxxxxx',
  141. 'dbname' => 'test'
  142. ));
  143. ]]></programlisting>
  144. </example>
  145. </sect3>
  146. <sect3 id="zend.db.adapter.connecting.factory">
  147. <title>Using the Zend_Db Factory</title>
  148. <para>
  149. As an alternative to using an adapter constructor directly, you
  150. can create an instance of an adapter using the static method
  151. <methodname>Zend_Db::factory()</methodname>. This method dynamically loads
  152. the adapter class file on demand using
  153. <link linkend="zend.loader.load.class">Zend_Loader::loadClass()</link>.
  154. </para>
  155. <para>
  156. The first argument is a string that names the base name of the
  157. adapter class. For example the string '<classname>Pdo_Mysql</classname>' corresponds
  158. to the class <classname>Zend_Db_Adapter_Pdo_Mysql</classname>. The second argument
  159. is the same array of parameters you would have given to the
  160. adapter constructor.
  161. </para>
  162. <example id="zend.db.adapter.connecting.factory.example">
  163. <title>Using the Adapter Factory Method</title>
  164. <programlisting language="php"><![CDATA[
  165. // We don't need the following statement because the
  166. // Zend_Db_Adapter_Pdo_Mysql file will be loaded for us by the Zend_Db
  167. // factory method.
  168. // require_once 'Zend/Db/Adapter/Pdo/Mysql.php';
  169. // Automatically load class Zend_Db_Adapter_Pdo_Mysql
  170. // and create an instance of it.
  171. $db = Zend_Db::factory('Pdo_Mysql', array(
  172. 'host' => '127.0.0.1',
  173. 'username' => 'webuser',
  174. 'password' => 'xxxxxxxx',
  175. 'dbname' => 'test'
  176. ));
  177. ]]></programlisting>
  178. </example>
  179. <para>
  180. If you create your own class that extends
  181. <classname>Zend_Db_Adapter_Abstract</classname>, but you do not name your
  182. class with the "<classname>Zend_Db_Adapter</classname>" package prefix, you can use
  183. the <methodname>factory()</methodname> method to load your adapter if you
  184. specify the leading portion of the adapter class with the
  185. 'adapterNamespace' key in the parameters array.
  186. </para>
  187. <example id="zend.db.adapter.connecting.factory.example2">
  188. <title>Using the Adapter Factory Method for a Custom Adapter Class</title>
  189. <programlisting language="php"><![CDATA[
  190. // We don't need to load the adapter class file
  191. // because it will be loaded for us by the Zend_Db factory method.
  192. // Automatically load class MyProject_Db_Adapter_Pdo_Mysql and create
  193. // an instance of it.
  194. $db = Zend_Db::factory('Pdo_Mysql', array(
  195. 'host' => '127.0.0.1',
  196. 'username' => 'webuser',
  197. 'password' => 'xxxxxxxx',
  198. 'dbname' => 'test',
  199. 'adapterNamespace' => 'MyProject_Db_Adapter'
  200. ));
  201. ]]></programlisting>
  202. </example>
  203. </sect3>
  204. <sect3 id="zend.db.adapter.connecting.factory-config">
  205. <title>Using Zend_Config with the Zend_Db Factory</title>
  206. <para>
  207. Optionally, you may specify either argument of the
  208. <methodname>factory()</methodname> method as an object of type
  209. <link linkend="zend.config">Zend_Config</link>.
  210. </para>
  211. <para>
  212. If the first argument is a config object, it is expected to
  213. contain a property named <property>adapter</property>, containing the
  214. string naming the adapter class name base. Optionally, the object
  215. may contain a property named <property>params</property>, with
  216. subproperties corresponding to adapter parameter names.
  217. This is used only if the second argument of the
  218. <methodname>factory()</methodname> method is absent.
  219. </para>
  220. <example id="zend.db.adapter.connecting.factory.example1">
  221. <title>Using the Adapter Factory Method with a Zend_Config Object</title>
  222. <para>
  223. In the example below, a <classname>Zend_Config</classname> object is created
  224. from an array. You can also load data from an external file using classes such
  225. as <link linkend="zend.config.adapters.ini">Zend_Config_Ini</link>
  226. and <link linkend="zend.config.adapters.xml">Zend_Config_Xml</link>.
  227. </para>
  228. <programlisting language="php"><![CDATA[
  229. $config = new Zend_Config(
  230. array(
  231. 'database' => array(
  232. 'adapter' => 'Mysqli',
  233. 'params' => array(
  234. 'host' => '127.0.0.1',
  235. 'dbname' => 'test',
  236. 'username' => 'webuser',
  237. 'password' => 'secret',
  238. )
  239. )
  240. )
  241. );
  242. $db = Zend_Db::factory($config->database);
  243. ]]></programlisting>
  244. </example>
  245. <para>
  246. The second argument of the <methodname>factory()</methodname> method may be
  247. an associative array containing entries corresponding to
  248. adapter parameters. This argument is optional. If the first
  249. argument is of type <classname>Zend_Config</classname>, it is assumed to contain all
  250. parameters, and the second argument is ignored.
  251. </para>
  252. </sect3>
  253. <sect3 id="zend.db.adapter.connecting.parameters">
  254. <title>Adapter Parameters</title>
  255. <para>
  256. The following list explains common parameters recognized by
  257. <classname>Zend_Db</classname> Adapter classes.
  258. </para>
  259. <itemizedlist>
  260. <listitem>
  261. <para>
  262. <emphasis>host</emphasis>:
  263. a string containing a hostname or IP address of the
  264. database server. If the database is running on the
  265. same host as the <acronym>PHP</acronym> application, you may use
  266. 'localhost' or '127.0.0.1'.
  267. </para>
  268. </listitem>
  269. <listitem>
  270. <para>
  271. <emphasis>username</emphasis>:
  272. account identifier for authenticating a connection to the
  273. <acronym>RDBMS</acronym> server.
  274. </para>
  275. </listitem>
  276. <listitem>
  277. <para>
  278. <emphasis>password</emphasis>:
  279. account password credential for authenticating a
  280. connection to the <acronym>RDBMS</acronym> server.
  281. </para>
  282. </listitem>
  283. <listitem>
  284. <para>
  285. <emphasis>dbname</emphasis>:
  286. database instance name on the <acronym>RDBMS</acronym> server.
  287. </para>
  288. </listitem>
  289. <listitem>
  290. <para>
  291. <emphasis>port</emphasis>:
  292. some <acronym>RDBMS</acronym> servers can accept network connections on a
  293. administrator-specified port number. The port
  294. parameter allow you to specify the port to which your
  295. <acronym>PHP</acronym> application connects, to match the port configured
  296. on the <acronym>RDBMS</acronym> server.
  297. </para>
  298. </listitem>
  299. <listitem>
  300. <para>
  301. <emphasis>charset</emphasis>:
  302. specify the charset used for the connection.
  303. </para>
  304. </listitem>
  305. <listitem>
  306. <para>
  307. <emphasis>options</emphasis>:
  308. this parameter is an associative array of options
  309. that are generic to all <classname>Zend_Db_Adapter</classname> classes.
  310. </para>
  311. </listitem>
  312. <listitem>
  313. <para>
  314. <emphasis>driver_options</emphasis>:
  315. this parameter is an associative array of additional
  316. options that are specific to a given database
  317. extension. One typical use of this parameter is to
  318. set attributes of a <acronym>PDO</acronym> driver.
  319. </para>
  320. </listitem>
  321. <listitem>
  322. <para>
  323. <emphasis>adapterNamespace</emphasis>:
  324. names the initial part of the class name for the
  325. adapter, instead of '<classname>Zend_Db_Adapter</classname>'. Use this if
  326. you need to use the <methodname>factory()</methodname> method to
  327. load a non-Zend database adapter class.
  328. </para>
  329. </listitem>
  330. </itemizedlist>
  331. <example id="zend.db.adapter.connecting.parameters.example1">
  332. <title>Passing the Case-Folding Option to the Factory</title>
  333. <para>
  334. You can specify this option by the constant
  335. <constant>Zend_Db::CASE_FOLDING</constant>.
  336. This corresponds to the <constant>ATTR_CASE</constant> attribute in
  337. <acronym>PDO</acronym> and <acronym>IBM</acronym> <acronym>DB2</acronym>
  338. database drivers, adjusting the case of string keys in query result sets. The
  339. option takes values <constant>Zend_Db::CASE_NATURAL</constant> (the default),
  340. <constant>Zend_Db::CASE_UPPER</constant>, and
  341. <constant>Zend_Db::CASE_LOWER</constant>.
  342. </para>
  343. <programlisting language="php"><![CDATA[
  344. $options = array(
  345. Zend_Db::CASE_FOLDING => Zend_Db::CASE_UPPER
  346. );
  347. $params = array(
  348. 'host' => '127.0.0.1',
  349. 'username' => 'webuser',
  350. 'password' => 'xxxxxxxx',
  351. 'dbname' => 'test',
  352. 'options' => $options
  353. );
  354. $db = Zend_Db::factory('Db2', $params);
  355. ]]></programlisting>
  356. </example>
  357. <example id="zend.db.adapter.connecting.parameters.example2">
  358. <title>Passing the Auto-Quoting Option to the Factory</title>
  359. <para>
  360. You can specify this option by the constant
  361. <constant>Zend_Db::AUTO_QUOTE_IDENTIFIERS</constant>. If the value
  362. is <constant>TRUE</constant> (the default), identifiers like table
  363. names, column names, and even aliases are delimited in all
  364. <acronym>SQL</acronym> syntax generated by the Adapter object. This makes it
  365. simple to use identifiers that contain <acronym>SQL</acronym> keywords, or
  366. special characters. If the value is <constant>FALSE</constant>,
  367. identifiers are not delimited automatically. If you need
  368. to delimit identifiers, you must do so yourself using the
  369. <methodname>quoteIdentifier()</methodname> method.
  370. </para>
  371. <programlisting language="php"><![CDATA[
  372. $options = array(
  373. Zend_Db::AUTO_QUOTE_IDENTIFIERS => false
  374. );
  375. $params = array(
  376. 'host' => '127.0.0.1',
  377. 'username' => 'webuser',
  378. 'password' => 'xxxxxxxx',
  379. 'dbname' => 'test',
  380. 'options' => $options
  381. );
  382. $db = Zend_Db::factory('Pdo_Mysql', $params);
  383. ]]></programlisting>
  384. </example>
  385. <example id="zend.db.adapter.connecting.parameters.example3">
  386. <title>Passing PDO Driver Options to the Factory</title>
  387. <programlisting language="php"><![CDATA[
  388. $pdoParams = array(
  389. PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true
  390. );
  391. $params = array(
  392. 'host' => '127.0.0.1',
  393. 'username' => 'webuser',
  394. 'password' => 'xxxxxxxx',
  395. 'dbname' => 'test',
  396. 'driver_options' => $pdoParams
  397. );
  398. $db = Zend_Db::factory('Pdo_Mysql', $params);
  399. echo $db->getConnection()
  400. ->getAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY);
  401. ]]></programlisting>
  402. </example>
  403. <example id="zend.db.adapter.connecting.parameters.example4">
  404. <title>Passing Serialization Options to the Factory</title>
  405. <programlisting language="php"><![CDATA[
  406. $options = array(
  407. Zend_Db::ALLOW_SERIALIZATION => false
  408. );
  409. $params = array(
  410. 'host' => '127.0.0.1',
  411. 'username' => 'webuser',
  412. 'password' => 'xxxxxxxx',
  413. 'dbname' => 'test',
  414. 'options' => $options
  415. );
  416. $db = Zend_Db::factory('Pdo_Mysql', $params);
  417. ]]></programlisting>
  418. </example>
  419. </sect3>
  420. <sect3 id="zend.db.adapter.connecting.getconnection">
  421. <title>Managing Lazy Connections</title>
  422. <para>
  423. Creating an instance of an Adapter class does not immediately
  424. connect to the <acronym>RDBMS</acronym> server. The Adapter saves the connection
  425. parameters, and makes the actual connection on demand, the
  426. first time you need to execute a query. This ensures that
  427. creating an Adapter object is quick and inexpensive. You can
  428. create an instance of an Adapter even if you are not certain
  429. that you need to run any database queries during the current
  430. request your application is serving.
  431. </para>
  432. <para>
  433. If you need to force the Adapter to connect to the <acronym>RDBMS</acronym>, use
  434. the <methodname>getConnection()</methodname> method. This method returns
  435. an object for the connection as represented by the respective
  436. <acronym>PHP</acronym> database extension. For example, if you use any of the
  437. Adapter classes for <acronym>PDO</acronym> drivers, then
  438. <methodname>getConnection()</methodname> returns the <acronym>PDO</acronym> object,
  439. after initiating it as a live connection to the specific database.
  440. </para>
  441. <para>
  442. It can be useful to force the connection if you want to catch
  443. any exceptions it throws as a result of invalid account
  444. credentials, or other failure to connect to the <acronym>RDBMS</acronym> server.
  445. These exceptions are not thrown until the connection is made,
  446. so it can help simplify your application code if you handle the
  447. exceptions in one place, instead of at the time of
  448. the first query against the database.
  449. </para>
  450. <para>
  451. Additionally, an adapter can get serialized to store it, for example,
  452. in a session variable. This can be very useful not only for the
  453. adapter itself, but for other objects that aggregate it, like a
  454. <classname>Zend_Db_Select</classname> object. By default, adapters are allowed
  455. to be serialized, if you don't want it, you should consider passing the
  456. <constant>Zend_Db::ALLOW_SERIALIZATION</constant> option with
  457. <constant>FALSE</constant>, see the example above. To respect lazy connections
  458. principle, the adapter won't reconnect itself after being unserialized. You must
  459. then call <methodname>getConnection()</methodname> yourself. You can make the
  460. adapter auto-reconnect by passing the
  461. <constant>Zend_Db::AUTO_RECONNECT_ON_UNSERIALIZE</constant> with
  462. <constant>TRUE</constant> as an adapter option.
  463. </para>
  464. <example id="zend.db.adapter.connecting.getconnection.example">
  465. <title>Handling Connection Exceptions</title>
  466. <programlisting language="php"><![CDATA[
  467. try {
  468. $db = Zend_Db::factory('Pdo_Mysql', $parameters);
  469. $db->getConnection();
  470. } catch (Zend_Db_Adapter_Exception $e) {
  471. // perhaps a failed login credential, or perhaps the RDBMS is not running
  472. } catch (Zend_Exception $e) {
  473. // perhaps factory() failed to load the specified Adapter class
  474. }
  475. ]]></programlisting>
  476. </example>
  477. </sect3>
  478. </sect2>
  479. <sect2 id="zend.db.adapter.example-database">
  480. <title>Example Database</title>
  481. <para>
  482. In the documentation for <classname>Zend_Db</classname> classes, we use a set of simple
  483. tables to illustrate usage of the classes and methods. These
  484. example tables could store information for tracking bugs in a
  485. software development project. The database contains four tables:
  486. </para>
  487. <itemizedlist>
  488. <listitem>
  489. <para>
  490. <emphasis>accounts</emphasis> stores
  491. information about each user of the bug-tracking database.
  492. </para>
  493. </listitem>
  494. <listitem>
  495. <para>
  496. <emphasis>products</emphasis> stores
  497. information about each product for which a bug can be
  498. logged.
  499. </para>
  500. </listitem>
  501. <listitem>
  502. <para>
  503. <emphasis>bugs</emphasis> stores information
  504. about bugs, including that current state of the bug, the
  505. person who reported the bug, the person who is assigned to
  506. fix the bug, and the person who is assigned to verify the
  507. fix.
  508. </para>
  509. </listitem>
  510. <listitem>
  511. <para>
  512. <emphasis>bugs_products</emphasis> stores a
  513. relationship between bugs and products. This implements a
  514. many-to-many relationship, because a given bug may be
  515. relevant to multiple products, and of course a given
  516. product can have multiple bugs.
  517. </para>
  518. </listitem>
  519. </itemizedlist>
  520. <para>
  521. The following <acronym>SQL</acronym> data definition language pseudocode describes the
  522. tables in this example database. These example tables are used
  523. extensively by the automated unit tests for <classname>Zend_Db</classname>.
  524. </para>
  525. <programlisting language="sql"><![CDATA[
  526. CREATE TABLE accounts (
  527. account_name VARCHAR(100) NOT NULL PRIMARY KEY
  528. );
  529. CREATE TABLE products (
  530. product_id INTEGER NOT NULL PRIMARY KEY,
  531. product_name VARCHAR(100)
  532. );
  533. CREATE TABLE bugs (
  534. bug_id INTEGER NOT NULL PRIMARY KEY,
  535. bug_description VARCHAR(100),
  536. bug_status VARCHAR(20),
  537. reported_by VARCHAR(100) REFERENCES accounts(account_name),
  538. assigned_to VARCHAR(100) REFERENCES accounts(account_name),
  539. verified_by VARCHAR(100) REFERENCES accounts(account_name)
  540. );
  541. CREATE TABLE bugs_products (
  542. bug_id INTEGER NOT NULL REFERENCES bugs,
  543. product_id INTEGER NOT NULL REFERENCES products,
  544. PRIMARY KEY (bug_id, product_id)
  545. );
  546. ]]></programlisting>
  547. <para>
  548. Also notice that the 'bugs' table contains multiple
  549. foreign key references to the 'accounts' table.
  550. Each of these foreign keys may reference a different row in the
  551. 'accounts' table for a given bug.
  552. </para>
  553. <para>
  554. The diagram below illustrates the physical data model of the
  555. example database.
  556. </para>
  557. <para>
  558. <inlinegraphic width="387" scale="100" align="center" valign="middle"
  559. fileref="figures/zend.db.adapter.example-database.png" format="PNG" />
  560. </para>
  561. </sect2>
  562. <sect2 id="zend.db.adapter.select">
  563. <title>Reading Query Results</title>
  564. <para>
  565. This section describes methods of the Adapter class with which you
  566. can run <acronym>SELECT</acronym> queries and retrieve the query results.
  567. </para>
  568. <sect3 id="zend.db.adapter.select.fetchall">
  569. <title>Fetching a Complete Result Set</title>
  570. <para>
  571. You can run a <acronym>SQL</acronym> <acronym>SELECT</acronym> query and retrieve
  572. its results in one step using the <methodname>fetchAll()</methodname> method.
  573. </para>
  574. <para>
  575. The first argument to this method is a string containing a
  576. <acronym>SELECT</acronym> statement. Alternatively, the first argument can be an
  577. object of class <link linkend="zend.db.select">Zend_Db_Select</link>.
  578. The Adapter automatically converts this object to a string
  579. representation of the <acronym>SELECT</acronym> statement.
  580. </para>
  581. <para>
  582. The second argument to <methodname>fetchAll()</methodname> is an array of
  583. values to substitute for parameter placeholders in the <acronym>SQL</acronym>
  584. statement.
  585. </para>
  586. <example id="zend.db.adapter.select.fetchall.example">
  587. <title>Using fetchAll()</title>
  588. <programlisting language="php"><![CDATA[
  589. $sql = 'SELECT * FROM bugs WHERE bug_id = ?';
  590. $result = $db->fetchAll($sql, 2);
  591. ]]></programlisting>
  592. </example>
  593. </sect3>
  594. <sect3 id="zend.db.adapter.select.fetch-mode">
  595. <title>Changing the Fetch Mode</title>
  596. <para>
  597. By default, <methodname>fetchAll()</methodname> returns an array of
  598. rows, each of which is an associative array. The keys of the
  599. associative array are the columns or column aliases named in
  600. the select query.
  601. </para>
  602. <para>
  603. You can specify a different style of fetching results using the
  604. <methodname>setFetchMode()</methodname> method. The modes supported are
  605. identified by constants:
  606. </para>
  607. <itemizedlist>
  608. <listitem>
  609. <para>
  610. <emphasis><constant>Zend_Db::FETCH_ASSOC</constant></emphasis>:
  611. return data in an array of associative arrays.
  612. The array keys are column names, as strings. This is the default fetch mode
  613. for <classname>Zend_Db_Adapter</classname> classes.
  614. </para>
  615. <para>
  616. Note that if your select-list contains more than one
  617. column with the same name, for example if they are from
  618. two different tables in a <acronym>JOIN</acronym>, there can be only one
  619. entry in the associative array for a given name.
  620. If you use the <constant>FETCH_ASSOC</constant> mode, you should specify
  621. column aliases in your <acronym>SELECT</acronym> query to ensure that the
  622. names result in unique array keys.
  623. </para>
  624. <para>
  625. By default, these strings are returned as they are
  626. returned by the database driver. This is typically the
  627. spelling of the column in the <acronym>RDBMS</acronym> server. You can
  628. specify the case for these strings, using the
  629. <constant>Zend_Db::CASE_FOLDING</constant> option.
  630. Specify this when instantiating the Adapter.
  631. See <link linkend="zend.db.adapter.connecting.parameters.example1">this
  632. example</link>
  633. </para>
  634. </listitem>
  635. <listitem>
  636. <para>
  637. <emphasis><constant>Zend_Db::FETCH_NUM</constant></emphasis>:
  638. return data in an array of arrays. The arrays are
  639. indexed by integers, corresponding to the position of
  640. the respective field in the select-list of the query.
  641. </para>
  642. </listitem>
  643. <listitem>
  644. <para>
  645. <emphasis><constant>Zend_Db::FETCH_BOTH</constant></emphasis>:
  646. return data in an array of arrays. The array keys are
  647. both strings as used in the <constant>FETCH_ASSOC</constant> mode, and
  648. integers as used in the <constant>FETCH_NUM</constant> mode. Note that the
  649. number of elements in the array is double that which
  650. would be in the array if you used either <constant>FETCH_ASSOC</constant>
  651. or <constant>FETCH_NUM</constant>.
  652. </para>
  653. </listitem>
  654. <listitem>
  655. <para>
  656. <emphasis><constant>Zend_Db::FETCH_COLUMN</constant></emphasis>:
  657. return data in an array of values. The value in each array
  658. is the value returned by one column of the result set.
  659. By default, this is the first column, indexed by 0.
  660. </para>
  661. </listitem>
  662. <listitem>
  663. <para>
  664. <emphasis><constant>Zend_Db::FETCH_OBJ</constant></emphasis>:
  665. return data in an array of objects. The default class
  666. is the <acronym>PHP</acronym> built-in class stdClass. Columns of the
  667. result set are available as public properties of the
  668. object.
  669. </para>
  670. </listitem>
  671. </itemizedlist>
  672. <example id="zend.db.adapter.select.fetch-mode.example">
  673. <title>Using setFetchMode()</title>
  674. <programlisting language="php"><![CDATA[
  675. $db->setFetchMode(Zend_Db::FETCH_OBJ);
  676. $result = $db->fetchAll('SELECT * FROM bugs WHERE bug_id = ?', 2);
  677. // $result is an array of objects
  678. echo $result[0]->bug_description;
  679. ]]></programlisting>
  680. </example>
  681. </sect3>
  682. <sect3 id="zend.db.adapter.select.fetchassoc">
  683. <title>Fetching a Result Set as an Associative Array</title>
  684. <para>
  685. The <methodname>fetchAssoc()</methodname> method returns data in an array
  686. of associative arrays, regardless of what value you have set
  687. for the fetch mode, using the first column as the array index.
  688. </para>
  689. <example id="zend.db.adapter.select.fetchassoc.example">
  690. <title>Using fetchAssoc()</title>
  691. <programlisting language="php"><![CDATA[
  692. $db->setFetchMode(Zend_Db::FETCH_OBJ);
  693. $result = $db->fetchAssoc(
  694. 'SELECT bug_id, bug_description, bug_status FROM bugs'
  695. );
  696. // $result is an array of associative arrays, in spite of the fetch mode
  697. echo $result[2]['bug_description']; // Description of Bug #2
  698. echo $result[1]['bug_description']; // Description of Bug #1
  699. ]]></programlisting>
  700. </example>
  701. </sect3>
  702. <sect3 id="zend.db.adapter.select.fetchcol">
  703. <title>Fetching a Single Column from a Result Set</title>
  704. <para>
  705. The <methodname>fetchCol()</methodname> method returns data in an array
  706. of values, regardless of the value you have set for the fetch mode.
  707. This only returns the first column returned by the query.
  708. Any other columns returned by the query are discarded.
  709. If you need to return a column other than the first, see
  710. <link linkend="zend.db.statement.fetching.fetchcolumn">this section</link>.
  711. </para>
  712. <example id="zend.db.adapter.select.fetchcol.example">
  713. <title>Using fetchCol()</title>
  714. <programlisting language="php"><![CDATA[
  715. $db->setFetchMode(Zend_Db::FETCH_OBJ);
  716. $result = $db->fetchCol(
  717. 'SELECT bug_description, bug_id FROM bugs WHERE bug_id = ?', 2);
  718. // contains bug_description; bug_id is not returned
  719. echo $result[0];
  720. ]]></programlisting>
  721. </example>
  722. </sect3>
  723. <sect3 id="zend.db.adapter.select.fetchpairs">
  724. <title>Fetching Key-Value Pairs from a Result Set</title>
  725. <para>
  726. The <methodname>fetchPairs()</methodname> method returns data in an array
  727. of key-value pairs, as an associative array with a single entry
  728. per row. The key of this associative array is taken from the
  729. first column returned by the <acronym>SELECT</acronym> query. The value is taken
  730. from the second column returned by the <acronym>SELECT</acronym> query. Any other
  731. columns returned by the query are discarded.
  732. </para>
  733. <para>
  734. You should design the <acronym>SELECT</acronym> query so that the first column
  735. returned has unique values. If there are duplicates values in
  736. the first column, entries in the associative array will be
  737. overwritten.
  738. </para>
  739. <example id="zend.db.adapter.select.fetchpairs.example">
  740. <title>Using fetchPairs()</title>
  741. <programlisting language="php"><![CDATA[
  742. $db->setFetchMode(Zend_Db::FETCH_OBJ);
  743. $result = $db->fetchPairs('SELECT bug_id, bug_status FROM bugs');
  744. echo $result[2];
  745. ]]></programlisting>
  746. </example>
  747. </sect3>
  748. <sect3 id="zend.db.adapter.select.fetchrow">
  749. <title>Fetching a Single Row from a Result Set</title>
  750. <para>
  751. The <methodname>fetchRow()</methodname> method returns data using the
  752. current fetch mode, but it returns only the first row
  753. fetched from the result set.
  754. </para>
  755. <example id="zend.db.adapter.select.fetchrow.example">
  756. <title>Using fetchRow()</title>
  757. <programlisting language="php"><![CDATA[
  758. $db->setFetchMode(Zend_Db::FETCH_OBJ);
  759. $result = $db->fetchRow('SELECT * FROM bugs WHERE bug_id = 2');
  760. // note that $result is a single object, not an array of objects
  761. echo $result->bug_description;
  762. ]]></programlisting>
  763. </example>
  764. </sect3>
  765. <sect3 id="zend.db.adapter.select.fetchone">
  766. <title>Fetching a Single Scalar from a Result Set</title>
  767. <para>
  768. The <methodname>fetchOne()</methodname> method is like a combination
  769. of <methodname>fetchRow()</methodname> with <methodname>fetchCol()</methodname>,
  770. in that it returns data only for the first row fetched from
  771. the result set, and it returns only the value of the first
  772. column in that row. Therefore it returns only a single
  773. scalar value, not an array or an object.
  774. </para>
  775. <example id="zend.db.adapter.select.fetchone.example">
  776. <title>Using fetchOne()</title>
  777. <programlisting language="php"><![CDATA[
  778. $result = $db->fetchOne('SELECT bug_status FROM bugs WHERE bug_id = 2');
  779. // this is a single string value
  780. echo $result;
  781. ]]></programlisting>
  782. </example>
  783. </sect3>
  784. </sect2>
  785. <sect2 id="zend.db.adapter.write">
  786. <title>Writing Changes to the Database</title>
  787. <para>
  788. You can use the Adapter class to write new data or change existing
  789. data in your database. This section describes methods to do these
  790. operations.
  791. </para>
  792. <sect3 id="zend.db.adapter.write.insert">
  793. <title>Inserting Data</title>
  794. <para>
  795. You can add new rows to a table in your database using the
  796. <methodname>insert()</methodname> method. The first argument is a string
  797. that names the table, and the second argument is an associative
  798. array, mapping column names to data values.
  799. </para>
  800. <example id="zend.db.adapter.write.insert.example">
  801. <title>Inserting in a Table</title>
  802. <programlisting language="php"><![CDATA[
  803. $data = array(
  804. 'created_on' => '2007-03-22',
  805. 'bug_description' => 'Something wrong',
  806. 'bug_status' => 'NEW'
  807. );
  808. $db->insert('bugs', $data);
  809. ]]></programlisting>
  810. </example>
  811. <para>
  812. Columns you exclude from the array of data are not specified to
  813. the database. Therefore, they follow the same rules that an
  814. <acronym>SQL</acronym> <acronym>INSERT</acronym> statement follows: if the column
  815. has a <acronym>DEFAULT</acronym> clause, the column takes that value in the row
  816. created, otherwise the column is left in a <constant>NULL</constant> state.
  817. </para>
  818. <para>
  819. By default, the values in your data array are inserted using
  820. parameters. This reduces risk of some types of security
  821. issues. You don't need to apply escaping or quoting to values
  822. in the data array.
  823. </para>
  824. <para>
  825. You might need values in the data array to be treated as <acronym>SQL</acronym>
  826. expressions, in which case they should not be quoted. By
  827. default, all data values passed as strings are treated as
  828. string literals. To specify that the value is an <acronym>SQL</acronym>
  829. expression and therefore should not be quoted, pass the value
  830. in the data array as an object of type <classname>Zend_Db_Expr</classname> instead
  831. of a plain string.
  832. </para>
  833. <example id="zend.db.adapter.write.insert.example2">
  834. <title>Inserting Expressions in a Table</title>
  835. <programlisting language="php"><![CDATA[
  836. $data = array(
  837. 'created_on' => new Zend_Db_Expr('CURDATE()'),
  838. 'bug_description' => 'Something wrong',
  839. 'bug_status' => 'NEW'
  840. );
  841. $db->insert('bugs', $data);
  842. ]]></programlisting>
  843. </example>
  844. </sect3>
  845. <sect3 id="zend.db.adapter.write.lastinsertid">
  846. <title>Retrieving a Generated Value</title>
  847. <para>
  848. Some <acronym>RDBMS</acronym> brands support auto-incrementing primary keys.
  849. A table defined this way generates a primary key value
  850. automatically during an <acronym>INSERT</acronym> of a new row. The return value
  851. of the <methodname>insert()</methodname> method is <emphasis>not</emphasis>
  852. the last inserted ID, because the table might not have an
  853. auto-incremented column. Instead, the return value is the
  854. number of rows affected (usually 1).
  855. </para>
  856. <para>
  857. If your table is defined with an auto-incrementing primary key,
  858. you can call the <methodname>lastInsertId()</methodname> method after the
  859. insert. This method returns the last value generated in the
  860. scope of the current database connection.
  861. </para>
  862. <example id="zend.db.adapter.write.lastinsertid.example-1">
  863. <title>Using lastInsertId() for an Auto-Increment Key</title>
  864. <programlisting language="php"><![CDATA[
  865. $db->insert('bugs', $data);
  866. // return the last value generated by an auto-increment column
  867. $id = $db->lastInsertId();
  868. ]]></programlisting>
  869. </example>
  870. <para>
  871. Some <acronym>RDBMS</acronym> brands support a sequence object, which generates
  872. unique values to serve as primary key values. To support
  873. sequences, the <methodname>lastInsertId()</methodname> method accepts two
  874. optional string arguments. These arguments name the table and
  875. the column, assuming you have followed the convention that a
  876. sequence is named using the table and column names for which
  877. the sequence generates values, and a suffix "_seq". This is
  878. based on the convention used by PostgreSQL when naming
  879. sequences for <constant>SERIAL</constant> columns. For example, a table "bugs" with
  880. primary key column "bug_id" would use a sequence named
  881. "bugs_bug_id_seq".
  882. </para>
  883. <example id="zend.db.adapter.write.lastinsertid.example-2">
  884. <title>Using lastInsertId() for a Sequence</title>
  885. <programlisting language="php"><![CDATA[
  886. $db->insert('bugs', $data);
  887. // return the last value generated by sequence 'bugs_bug_id_seq'.
  888. $id = $db->lastInsertId('bugs', 'bug_id');
  889. // alternatively, return the last value generated by sequence 'bugs_seq'.
  890. $id = $db->lastInsertId('bugs');
  891. ]]></programlisting>
  892. </example>
  893. <para>
  894. If the name of your sequence object does not follow this naming
  895. convention, use the <methodname>lastSequenceId()</methodname> method
  896. instead. This method takes a single string argument, naming
  897. the sequence literally.
  898. </para>
  899. <example id="zend.db.adapter.write.lastinsertid.example-3">
  900. <title>Using lastSequenceId()</title>
  901. <programlisting language="php"><![CDATA[
  902. $db->insert('bugs', $data);
  903. // return the last value generated by sequence 'bugs_id_gen'.
  904. $id = $db->lastSequenceId('bugs_id_gen');
  905. ]]></programlisting>
  906. </example>
  907. <para>
  908. For <acronym>RDBMS</acronym> brands that don't support sequences, including MariaDB,
  909. MySQL, Microsoft <acronym>SQL</acronym> Server, and SQLite, the arguments to the
  910. <methodname>lastInsertId()</methodname> method are ignored, and the value returned
  911. is the most recent value generated for any table by <acronym>INSERT</acronym>
  912. operations during the current connection. For these <acronym>RDBMS</acronym> brands,
  913. the <methodname>lastSequenceId()</methodname> method always returns
  914. <constant>NULL</constant>.
  915. </para>
  916. <note>
  917. <title>Why Not Use "SELECT MAX(id) FROM table"?</title>
  918. <para>
  919. Sometimes this query returns the most recent primary key
  920. value inserted into the table. However, this technique
  921. is not safe to use in an environment where multiple clients are
  922. inserting records to the database. It is possible, and
  923. therefore is bound to happen eventually, that another
  924. client inserts another row in the instant between the
  925. insert performed by your client application and your query
  926. for the <methodname>MAX(id)</methodname> value. Thus the value returned does
  927. not identify the row you inserted, it identifies the row
  928. inserted by some other client. There is no way to know
  929. when this has happened.
  930. </para>
  931. <para>
  932. Using a strong transaction isolation mode such as
  933. "repeatable read" can mitigate this risk, but some <acronym>RDBMS</acronym>
  934. brands don't support the transaction isolation required for
  935. this, or else your application may use a lower transaction
  936. isolation mode by design.
  937. </para>
  938. <para>
  939. Furthermore, using an expression like "<command>MAX(id)+1</command>" to generate
  940. a new value for a primary key is not safe, because two clients
  941. could do this query simultaneously, and then both use the same
  942. calculated value for their next <acronym>INSERT</acronym> operation.
  943. </para>
  944. <para>
  945. All <acronym>RDBMS</acronym> brands provide mechanisms to generate unique
  946. values, and to return the last value generated. These
  947. mechanisms necessarily work outside of the scope of
  948. transaction isolation, so there is no chance of two clients
  949. generating the same value, and there is no chance that the
  950. value generated by another client could be reported to your
  951. client's connection as the last value generated.
  952. </para>
  953. </note>
  954. </sect3>
  955. <sect3 id="zend.db.adapter.write.update">
  956. <title>Updating Data</title>
  957. <para>
  958. You can update rows in a database table using the
  959. <methodname>update()</methodname> method of an Adapter. This method takes
  960. three arguments: the first is the name of the table; the
  961. second is an associative array mapping columns to change to new
  962. values to assign to these columns.
  963. </para>
  964. <para>
  965. The values in the data array are treated as string literals.
  966. See <link linkend="zend.db.adapter.write.insert">this section</link>
  967. for information on using <acronym>SQL</acronym> expressions in the data array.
  968. </para>
  969. <para>
  970. The third argument is a string containing an <acronym>SQL</acronym> expression
  971. that is used as criteria for the rows to change. The values
  972. and identifiers in this argument are not quoted or escaped.
  973. You are responsible for ensuring that any dynamic content is
  974. interpolated into this string safely.
  975. See <link linkend="zend.db.adapter.quoting">this section</link>
  976. for methods to help you do this.
  977. </para>
  978. <para>
  979. The return value is the number of rows affected by the update
  980. operation.
  981. </para>
  982. <example id="zend.db.adapter.write.update.example">
  983. <title>Updating Rows</title>
  984. <programlisting language="php"><![CDATA[
  985. $data = array(
  986. 'updated_on' => '2007-03-23',
  987. 'bug_status' => 'FIXED'
  988. );
  989. $n = $db->update('bugs', $data, 'bug_id = 2');
  990. ]]></programlisting>
  991. </example>
  992. <para>
  993. If you omit the third argument, then all rows in the database
  994. table are updated with the values specified in the data array.
  995. </para>
  996. <para>
  997. If you provide an array of strings as the third argument, these
  998. strings are joined together as terms in an expression separated
  999. by <constant>AND</constant> operators.
  1000. </para>
  1001. <para>
  1002. If you provide an array of arrays as the third argument, the
  1003. values will be automatically quoted into the keys. These
  1004. will then be joined together as terms, separated by
  1005. <constant>AND</constant> operators.
  1006. </para>
  1007. <example id="zend.db.adapter.write.update.example-array">
  1008. <title>Updating Rows Using an Array of Expressions</title>
  1009. <programlisting language="php"><![CDATA[
  1010. $data = array(
  1011. 'updated_on' => '2007-03-23',
  1012. 'bug_status' => 'FIXED'
  1013. );
  1014. $where[] = "reported_by = 'goofy'";
  1015. $where[] = "bug_status = 'OPEN'";
  1016. $n = $db->update('bugs', $data, $where);
  1017. // Resulting SQL is:
  1018. // UPDATE "bugs" SET "update_on" = '2007-03-23', "bug_status" = 'FIXED'
  1019. // WHERE ("reported_by" = 'goofy') AND ("bug_status" = 'OPEN')
  1020. ]]></programlisting>
  1021. </example>
  1022. <example id="zend.db.adapter.write.update.example-arrayofarrays">
  1023. <title>Updating Rows Using an Array of Arrays</title>
  1024. <programlisting language="php"><![CDATA[
  1025. $data = array(
  1026. 'updated_on' => '2007-03-23',
  1027. 'bug_status' => 'FIXED'
  1028. );
  1029. $where['reported_by = ?'] = 'goofy';
  1030. $where['bug_status = ?'] = 'OPEN';
  1031. $n = $db->update('bugs', $data, $where);
  1032. // Resulting SQL is:
  1033. // UPDATE "bugs" SET "update_on" = '2007-03-23', "bug_status" = 'FIXED'
  1034. // WHERE ("reported_by" = 'goofy') AND ("bug_status" = 'OPEN')
  1035. ]]></programlisting>
  1036. </example>
  1037. </sect3>
  1038. <sect3 id="zend.db.adapter.write.delete">
  1039. <title>Deleting Data</title>
  1040. <para>
  1041. You can delete rows from a database table using the
  1042. <methodname>delete()</methodname> method. This method takes two arguments:
  1043. the first is a string naming the table.
  1044. </para>
  1045. <para>
  1046. The second argument is a string containing an <acronym>SQL</acronym> expression
  1047. that is used as criteria for the rows to delete. The values
  1048. and identifiers in this argument are not quoted or escaped.
  1049. You are responsible for ensuring that any dynamic content is
  1050. interpolated into this string safely.
  1051. See <link linkend="zend.db.adapter.quoting"> this section</link>
  1052. for methods to help you do this.
  1053. </para>
  1054. <para>
  1055. The return value is the number of rows affected by the delete
  1056. operation.
  1057. </para>
  1058. <example id="zend.db.adapter.write.delete.example">
  1059. <title>Deleting Rows</title>
  1060. <programlisting language="php"><![CDATA[
  1061. $n = $db->delete('bugs', 'bug_id = 3');
  1062. ]]></programlisting>
  1063. </example>
  1064. <para>
  1065. If you omit the second argument, the result is that all rows in
  1066. the database table are deleted.
  1067. </para>
  1068. <para>
  1069. If you provide an array of strings as the second argument, these
  1070. strings are joined together as terms in an expression separated
  1071. by <constant>AND</constant> operators.
  1072. </para>
  1073. <para>
  1074. If you provide an array of arrays as the second argument, the
  1075. values will be automatically quoted into the keys. These
  1076. will then be joined together as terms, separated by
  1077. <constant>AND</constant> operators.
  1078. </para>
  1079. </sect3>
  1080. </sect2>
  1081. <sect2 id="zend.db.adapter.quoting">
  1082. <title>Quoting Values and Identifiers</title>
  1083. <para>
  1084. When you form <acronym>SQL</acronym> queries, often it is the case that you need to
  1085. include the values of <acronym>PHP</acronym> variables in <acronym>SQL</acronym>
  1086. expressions. This is risky, because if the value in a <acronym>PHP</acronym> string
  1087. contains certain symbols, such as the quote symbol, it could result in invalid
  1088. <acronym>SQL</acronym>. For example, notice the imbalanced quote characters in the
  1089. following query:
  1090. </para>
  1091. <programlisting language="php"><![CDATA[
  1092. $name = "O'Reilly";
  1093. $sql = "SELECT * FROM bugs WHERE reported_by = '$name'";
  1094. echo $sql;
  1095. // SELECT * FROM bugs WHERE reported_by = 'O'Reilly'
  1096. ]]></programlisting>
  1097. <para>
  1098. Even worse is the risk that such code mistakes might be exploited
  1099. deliberately by a person who is trying to manipulate the function
  1100. of your web application. If they can specify the value of a <acronym>PHP</acronym>
  1101. variable through the use of an <acronym>HTTP</acronym> parameter or other mechanism,
  1102. they might be able to make your <acronym>SQL</acronym> queries do things that you
  1103. didn't intend them to do, such as return data to which the person
  1104. should not have privilege to read. This is a serious and widespread
  1105. technique for violating application security, known as "SQL Injection" (see <ulink
  1106. url="http://en.wikipedia.org/wiki/SQL_Injection">http://en.wikipedia.org/wiki/SQL_Injection</ulink>).
  1107. </para>
  1108. <para>
  1109. The <classname>Zend_Db</classname> Adapter class provides convenient functions to help
  1110. you reduce vulnerabilities to <acronym>SQL</acronym> Injection attacks in your
  1111. <acronym>PHP</acronym> code. The solution is to escape special characters such as quotes
  1112. in <acronym>PHP</acronym> values before they are interpolated into your
  1113. <acronym>SQL</acronym> strings. This protects against both accidental and deliberate
  1114. manipulation of <acronym>SQL</acronym> strings by <acronym>PHP</acronym> variables that
  1115. contain special characters.
  1116. </para>
  1117. <sect3 id="zend.db.adapter.quoting.quote">
  1118. <title>Using quote()</title>
  1119. <para>
  1120. The <methodname>quote()</methodname> method accepts a single argument, a
  1121. scalar string value. It returns the value with special
  1122. characters escaped in a manner appropriate for the <acronym>RDBMS</acronym> you
  1123. are using, and surrounded by string value delimiters. The
  1124. standard <acronym>SQL</acronym> string value delimiter is the single-quote
  1125. (').
  1126. </para>
  1127. <example id="zend.db.adapter.quoting.quote.example">
  1128. <title>Using quote()</title>
  1129. <programlisting language="php"><![CDATA[
  1130. $name = $db->quote("O'Reilly");
  1131. echo $name;
  1132. // 'O\'Reilly'
  1133. $sql = "SELECT * FROM bugs WHERE reported_by = $name";
  1134. echo $sql;
  1135. // SELECT * FROM bugs WHERE reported_by = 'O\'Reilly'
  1136. ]]></programlisting>
  1137. </example>
  1138. <para>
  1139. Note that the return value of <methodname>quote()</methodname> includes the
  1140. quote delimiters around the string. This is different from
  1141. some functions that escape special characters but do not add
  1142. the quote delimiters, for example <ulink
  1143. url="http://www.php.net/mysqli_real_escape_string">mysql_real_escape_string()</ulink>.
  1144. </para>
  1145. <para>
  1146. Values may need to be quoted or not quoted according to the <acronym>SQL</acronym>
  1147. datatype context in which they are used. For instance, in some
  1148. <acronym>RDBMS</acronym> brands, an integer value must not be quoted as a string
  1149. if it is compared to an integer-type column or expression.
  1150. In other words, the following is an error in some <acronym>SQL</acronym>
  1151. implementations, assuming <property>intColumn</property> has a
  1152. <acronym>SQL</acronym> datatype of <constant>INTEGER</constant>
  1153. </para>
  1154. <programlisting language="php"><![CDATA[
  1155. SELECT * FROM atable WHERE intColumn = '123'
  1156. ]]></programlisting>
  1157. <para>
  1158. You can use the optional second argument to the
  1159. <methodname>quote()</methodname> method to apply quoting selectively for
  1160. the <acronym>SQL</acronym> datatype you specify.
  1161. </para>
  1162. <example id="zend.db.adapter.quoting.quote.example-2">
  1163. <title>Using quote() with a SQL Type</title>
  1164. <programlisting language="php"><![CDATA[
  1165. $value = '1234';
  1166. $sql = 'SELECT * FROM atable WHERE intColumn = '
  1167. . $db->quote($value, 'INTEGER');
  1168. ]]></programlisting>
  1169. </example>
  1170. <para>
  1171. Each <classname>Zend_Db_Adapter</classname> class has encoded the names of numeric
  1172. <acronym>SQL</acronym> datatypes for the respective brand of
  1173. <acronym>RDBMS</acronym>. You can also use the constants
  1174. <constant>Zend_Db::INT_TYPE</constant>, <constant>Zend_Db::BIGINT_TYPE</constant>,
  1175. and <constant>Zend_Db::FLOAT_TYPE</constant> to write code in a more
  1176. <acronym>RDBMS</acronym>-independent way.
  1177. </para>
  1178. <para>
  1179. <classname>Zend_Db_Table</classname> specifies <acronym>SQL</acronym> types to
  1180. <methodname>quote()</methodname> automatically when generating
  1181. <acronym>SQL</acronym> queries that reference a table's key columns.
  1182. </para>
  1183. </sect3>
  1184. <sect3 id="zend.db.adapter.quoting.quote-into">
  1185. <title>Using quoteInto()</title>
  1186. <para>
  1187. The most typical usage of quoting is to interpolate a <acronym>PHP</acronym>
  1188. variable into a <acronym>SQL</acronym> expression or statement. You can use the
  1189. <methodname>quoteInto()</methodname> method to do this in one step. This
  1190. method takes two arguments: the first argument is a string
  1191. containing a placeholder symbol (?), and the
  1192. second argument is a value or <acronym>PHP</acronym> variable that should be
  1193. substituted for that placeholder.
  1194. </para>
  1195. <para>
  1196. The placeholder symbol is the same symbol used by many <acronym>RDBMS</acronym>
  1197. brands for positional parameters, but the
  1198. <methodname>quoteInto()</methodname> method only emulates query parameters.
  1199. The method simply interpolates the value into the string,
  1200. escapes special characters, and applies quotes around it.
  1201. True query parameters maintain the separation between the <acronym>SQL</acronym>
  1202. string and the parameters as the statement is parsed in the
  1203. <acronym>RDBMS</acronym> server.
  1204. </para>
  1205. <example id="zend.db.adapter.quoting.quote-into.example">
  1206. <title>Using quoteInto()</title>
  1207. <programlisting language="php"><![CDATA[
  1208. $sql = $db->quoteInto("SELECT * FROM bugs WHERE reported_by = ?", "O'Reilly");
  1209. echo $sql;
  1210. // SELECT * FROM bugs WHERE reported_by = 'O\'Reilly'
  1211. ]]></programlisting>
  1212. </example>
  1213. <para>
  1214. You can use the optional third parameter of
  1215. <methodname>quoteInto()</methodname> to specify the <acronym>SQL</acronym> datatype.
  1216. Numeric datatypes are not quoted, and other types are quoted.
  1217. </para>
  1218. <example id="zend.db.adapter.quoting.quote-into.example-2">
  1219. <title>Using quoteInto() with a SQL Type</title>
  1220. <programlisting language="php"><![CDATA[
  1221. $sql = $db
  1222. ->quoteInto("SELECT * FROM bugs WHERE bug_id = ?", '1234', 'INTEGER');
  1223. echo $sql;
  1224. // SELECT * FROM bugs WHERE reported_by = 1234
  1225. ]]></programlisting>
  1226. </example>
  1227. </sect3>
  1228. <sect3 id="zend.db.adapter.quoting.quote-identifier">
  1229. <title>Using quoteIdentifier()</title>
  1230. <para>
  1231. Values are not the only part of <acronym>SQL</acronym> syntax that might need to
  1232. be variable. If you use <acronym>PHP</acronym> variables to name tables, columns,
  1233. or other identifiers in your <acronym>SQL</acronym> statements, you might need to
  1234. quote these strings too. By default, <acronym>SQL</acronym> identifiers have
  1235. syntax rules like <acronym>PHP</acronym> and most other programming languages.
  1236. For example, identifiers should not contain spaces, certain
  1237. punctuation or special characters, or international characters.
  1238. Also certain words are reserved for <acronym>SQL</acronym> syntax, and should not
  1239. be used as identifiers.
  1240. </para>
  1241. <para>
  1242. However, <acronym>SQL</acronym> has a feature called
  1243. <emphasis>delimited identifiers</emphasis>, which allows broader choices for the
  1244. spelling of identifiers. If you enclose a <acronym>SQL</acronym> identifier in the
  1245. proper types of quotes, you can use identifiers with spellings that would be invalid
  1246. without the quotes. Delimited identifiers can contain spaces,
  1247. punctuation, or international characters. You can also use <acronym>SQL</acronym>
  1248. reserved words if you enclose them in identifier delimiters.
  1249. </para>
  1250. <para>
  1251. The <methodname>quoteIdentifier()</methodname> method works like
  1252. <methodname>quote()</methodname>, but it applies the identifier delimiter
  1253. characters to the string according to the type of Adapter you
  1254. use. For example, standard <acronym>SQL</acronym> uses double-quotes
  1255. (") for identifier delimiters, and most <acronym>RDBMS</acronym>
  1256. brands use that symbol. MySQL uses back-quotes (`) by default. The
  1257. <methodname>quoteIdentifier()</methodname> method also escapes special
  1258. characters within the string argument.
  1259. </para>
  1260. <example id="zend.db.adapter.quoting.quote-identifier.example">
  1261. <title>Using quoteIdentifier()</title>
  1262. <programlisting language="php"><![CDATA[
  1263. // we might have a table name that is an SQL reserved word
  1264. $tableName = $db->quoteIdentifier("order");
  1265. $sql = "SELECT * FROM $tableName";
  1266. echo $sql
  1267. // SELECT * FROM "order"
  1268. ]]></programlisting>
  1269. </example>
  1270. <para>
  1271. <acronym>SQL</acronym> delimited identifiers are case-sensitive, unlike unquoted
  1272. identifiers. Therefore, if you use delimited identifiers, you
  1273. must use the spelling of the identifier exactly as it is stored
  1274. in your schema, including the case of the letters.
  1275. </para>
  1276. <para>
  1277. In most cases where <acronym>SQL</acronym> is generated within
  1278. <classname>Zend_Db</classname> classes, the default is that all identifiers are
  1279. delimited automatically. You can change this behavior with the option
  1280. <constant>Zend_Db::AUTO_QUOTE_IDENTIFIERS</constant>. Specify this
  1281. when instantiating the Adapter.
  1282. See <link linkend="zend.db.adapter.connecting.parameters.example2">this
  1283. example</link>.
  1284. </para>
  1285. </sect3>
  1286. </sect2>
  1287. <sect2 id="zend.db.adapter.transactions">
  1288. <title>Controlling Database Transactions</title>
  1289. <para>
  1290. Databases define transactions as logical units of work that can be
  1291. committed or rolled back as a single change, even if they operate
  1292. on multiple tables. All queries to a database are executed within
  1293. the context of a transaction, even if the database driver manages
  1294. them implicitly. This is called <emphasis>auto-commit</emphasis>
  1295. mode, in which the database driver creates a transaction for every
  1296. statement you execute, and commits that transaction after your
  1297. <acronym>SQL</acronym> statement has been executed. By default, all
  1298. <classname>Zend_Db</classname> Adapter classes operate in auto-commit mode.
  1299. </para>
  1300. <para>
  1301. Alternatively, you can specify the beginning and resolution of a
  1302. transaction, and thus control how many <acronym>SQL</acronym> queries are included in
  1303. a single group that is committed (or rolled back) as a single
  1304. operation. Use the <methodname>beginTransaction()</methodname> method to
  1305. initiate a transaction. Subsequent <acronym>SQL</acronym> statements are executed in
  1306. the context of the same transaction until you resolve it
  1307. explicitly.
  1308. </para>
  1309. <para>
  1310. To resolve the transaction, use either the <methodname>commit()</methodname> or
  1311. <methodname>rollBack()</methodname> methods. The <methodname>commit()</methodname>
  1312. method marks changes made during your transaction as committed, which
  1313. means the effects of these changes are shown in queries run in
  1314. other transactions.
  1315. </para>
  1316. <para>
  1317. The <methodname>rollBack()</methodname> method does the opposite: it discards
  1318. the changes made during your transaction. The changes are
  1319. effectively undone, and the state of the data returns to how it was
  1320. before you began your transaction. However, rolling back your
  1321. transaction has no effect on changes made by other transactions
  1322. running concurrently.
  1323. </para>
  1324. <para>
  1325. After you resolve this transaction, <classname>Zend_Db_Adapter</classname>
  1326. returns to auto-commit mode until you call
  1327. <methodname>beginTransaction()</methodname> again.
  1328. </para>
  1329. <example id="zend.db.adapter.transactions.example">
  1330. <title>Managing a Transaction to Ensure Consistency</title>
  1331. <programlisting language="php"><![CDATA[
  1332. // Start a transaction explicitly.
  1333. $db->beginTransaction();
  1334. try {
  1335. // Attempt to execute one or more queries:
  1336. $db->query(...);
  1337. $db->query(...);
  1338. $db->query(...);
  1339. // If all succeed, commit the transaction and all changes
  1340. // are committed at once.
  1341. $db->commit();
  1342. } catch (Exception $e) {
  1343. // If any of the queries failed and threw an exception,
  1344. // we want to roll back the whole transaction, reversing
  1345. // changes made in the transaction, even those that succeeded.
  1346. // Thus all changes are committed together, or none are.
  1347. $db->rollBack();
  1348. echo $e->getMessage();
  1349. }
  1350. ]]></programlisting>
  1351. </example>
  1352. </sect2>
  1353. <sect2 id="zend.db.adapter.list-describe">
  1354. <title>Listing and Describing Tables</title>
  1355. <para>
  1356. The <methodname>listTables()</methodname> method returns an array of strings,
  1357. naming all tables in the current database.
  1358. </para>
  1359. <para>
  1360. The <methodname>describeTable()</methodname> method returns an associative
  1361. array of metadata about a table. Specify the name of the table
  1362. as a string in the first argument to this method. The second
  1363. argument is optional, and names the schema in which the table
  1364. exists.
  1365. </para>
  1366. <para>
  1367. The keys of the associative array returned are the column names of
  1368. the table. The value corresponding to each column is also an
  1369. associative array, with the following keys and values:
  1370. </para>
  1371. <table frame="all" cellpadding="5" id="zend.db.adapter.list-describe.metadata">
  1372. <title>Metadata Fields Returned by describeTable()</title>
  1373. <tgroup cols="3" align="left" colsep="1" rowsep="1">
  1374. <thead>
  1375. <row>
  1376. <entry>Key</entry>
  1377. <entry>Type</entry>
  1378. <entry>Description</entry>
  1379. </row>
  1380. </thead>
  1381. <tbody>
  1382. <row>
  1383. <entry><constant>SCHEMA_NAME</constant></entry>
  1384. <entry>(string)</entry>
  1385. <entry>Name of the database schema in which this table exists.</entry>
  1386. </row>
  1387. <row>
  1388. <entry><constant>TABLE_NAME</constant></entry>
  1389. <entry>(string)</entry>
  1390. <entry>Name of the table to which this column belongs.</entry>
  1391. </row>
  1392. <row>
  1393. <entry><constant>COLUMN_NAME</constant></entry>
  1394. <entry>(string)</entry>
  1395. <entry>Name of the column.</entry>
  1396. </row>
  1397. <row>
  1398. <entry><constant>COLUMN_POSITION</constant></entry>
  1399. <entry>(integer)</entry>
  1400. <entry>Ordinal position of the column in the table.</entry>
  1401. </row>
  1402. <row>
  1403. <entry><constant>DATA_TYPE</constant></entry>
  1404. <entry>(string)</entry>
  1405. <entry><acronym>RDBMS</acronym> name of the datatype of the column.</entry>
  1406. </row>
  1407. <row>
  1408. <entry><constant>DEFAULT</constant></entry>
  1409. <entry>(string)</entry>
  1410. <entry>Default value for the column, if any.</entry>
  1411. </row>
  1412. <row>
  1413. <entry><constant>NULLABLE</constant></entry>
  1414. <entry>(boolean)</entry>
  1415. <entry>
  1416. <constant>TRUE</constant> if the column accepts <acronym>SQL</acronym>
  1417. <constant>NULL</constant>'s, <constant>FALSE</constant> if the
  1418. column has a <constant>NOT</constant> <constant>NULL</constant>
  1419. constraint.
  1420. </entry>
  1421. </row>
  1422. <row>
  1423. <entry><constant>LENGTH</constant></entry>
  1424. <entry>(integer)</entry>
  1425. <entry>
  1426. Length or size of the column as reported by the
  1427. <acronym>RDBMS</acronym>.
  1428. </entry>
  1429. </row>
  1430. <row>
  1431. <entry><constant>SCALE</constant></entry>
  1432. <entry>(integer)</entry>
  1433. <entry>
  1434. Scale of <acronym>SQL</acronym> <constant>NUMERIC</constant> or
  1435. <constant>DECIMAL</constant> type.
  1436. </entry>
  1437. </row>
  1438. <row>
  1439. <entry><constant>PRECISION</constant></entry>
  1440. <entry>(integer)</entry>
  1441. <entry>
  1442. Precision of <acronym>SQL</acronym> <constant>NUMERIC</constant> or
  1443. <constant>DECIMAL</constant> type.
  1444. </entry>
  1445. </row>
  1446. <row>
  1447. <entry><constant>UNSIGNED</constant></entry>
  1448. <entry>(boolean)</entry>
  1449. <entry>
  1450. <constant>TRUE</constant> if an integer-based type is reported as
  1451. <constant>UNSIGNED</constant>.
  1452. </entry>
  1453. </row>
  1454. <row>
  1455. <entry><constant>PRIMARY</constant></entry>
  1456. <entry>(boolean)</entry>
  1457. <entry>
  1458. <constant>TRUE</constant> if the column is part of the primary key of
  1459. this table.
  1460. </entry>
  1461. </row>
  1462. <row>
  1463. <entry><constant>PRIMARY_POSITION</constant></entry>
  1464. <entry>(integer)</entry>
  1465. <entry>Ordinal position (1-based) of the column in the primary key.</entry>
  1466. </row>
  1467. <row>
  1468. <entry><constant>IDENTITY</constant></entry>
  1469. <entry>(boolean)</entry>
  1470. <entry>
  1471. <constant>TRUE</constant> if the column uses an auto-generated value.
  1472. </entry>
  1473. </row>
  1474. </tbody>
  1475. </tgroup>
  1476. </table>
  1477. <note>
  1478. <title>How the IDENTITY Metadata Field Relates to Specific RDBMSs</title>
  1479. <para>
  1480. The <constant>IDENTITY</constant> metadata field was chosen as an 'idiomatic' term
  1481. to represent a relation to surrogate keys. This field can be
  1482. commonly known by the following values:-
  1483. </para>
  1484. <itemizedlist>
  1485. <listitem>
  1486. <para>
  1487. <constant>IDENTITY</constant> - <acronym>DB2</acronym>,
  1488. <acronym>MSSQL</acronym>
  1489. </para>
  1490. </listitem>
  1491. <listitem>
  1492. <para>
  1493. <constant>AUTO_INCREMENT</constant> - MySQL/MariaDB
  1494. </para>
  1495. </listitem>
  1496. <listitem>
  1497. <para>
  1498. <constant>SERIAL</constant> - PostgreSQL
  1499. </para>
  1500. </listitem>
  1501. <listitem>
  1502. <para>
  1503. <constant>SEQUENCE</constant> - Oracle
  1504. </para>
  1505. </listitem>
  1506. </itemizedlist>
  1507. </note>
  1508. <para>
  1509. If no table exists matching the table name and optional schema name
  1510. specified, then <methodname>describeTable()</methodname> returns an empty array.
  1511. </para>
  1512. </sect2>
  1513. <sect2 id="zend.db.adapter.closing">
  1514. <title>Closing a Connection</title>
  1515. <para>
  1516. Normally it is not necessary to close a database connection. <acronym>PHP</acronym>
  1517. automatically cleans up all resources and the end of a request.
  1518. Database extensions are designed to close the connection as the
  1519. reference to the resource object is cleaned up.
  1520. </para>
  1521. <para>
  1522. However, if you have a long-duration <acronym>PHP</acronym> script that initiates many
  1523. database connections, you might need to close the connection, to avoid
  1524. exhausting the capacity of your <acronym>RDBMS</acronym> server. You can use the
  1525. Adapter's <methodname>closeConnection()</methodname> method to explicitly close
  1526. the underlying database connection.
  1527. </para>
  1528. <para>
  1529. Since release 1.7.2, you could check you are currently connected to the
  1530. <acronym>RDBMS</acronym> server with the method <methodname>isConnected()</methodname>.
  1531. This means that a connection resource has been initiated and wasn't closed. This
  1532. function is not currently able to test for example a server side closing of the
  1533. connection. This is internally use to close the connection. It allow you to close the
  1534. connection multiple times without errors. It was already the case before 1.7.2 for
  1535. <acronym>PDO</acronym> adapters but not for the others.
  1536. </para>
  1537. <example id="zend.db.adapter.closing.example">
  1538. <title>Closing a Database Connection</title>
  1539. <programlisting language="php"><![CDATA[
  1540. $db->closeConnection();
  1541. ]]></programlisting>
  1542. </example>
  1543. <note>
  1544. <title>Does Zend_Db Support Persistent Connections?</title>
  1545. <para>
  1546. Yes, persistence is supported through the addition of
  1547. the <property>persistent</property> flag set to <constant>TRUE</constant> in the
  1548. configuration (not driver_configuration) of an adapter
  1549. in <classname>Zend_Db</classname>.
  1550. </para>
  1551. <example id="zend.db.adapter.connecting.persistence.example">
  1552. <title>Using the Persitence Flag with the Oracle Adapter</title>
  1553. <programlisting language="php"><![CDATA[
  1554. $db = Zend_Db::factory('Oracle', array(
  1555. 'host' => '127.0.0.1',
  1556. 'username' => 'webuser',
  1557. 'password' => 'xxxxxxxx',
  1558. 'dbname' => 'test',
  1559. 'persistent' => true
  1560. ));
  1561. ]]></programlisting>
  1562. </example>
  1563. <para>
  1564. Please note that using persistent connections can cause an
  1565. excess of idle connections on the <acronym>RDBMS</acronym> server, which causes
  1566. more problems than any performance gain you might achieve by
  1567. reducing the overhead of making connections.
  1568. </para>
  1569. <para>
  1570. Database connections have state. That is, some objects in the
  1571. <acronym>RDBMS</acronym> server exist in session scope. Examples are locks, user
  1572. variables, temporary tables, and information about the most
  1573. recently executed query, such as rows affected, and last
  1574. generated id value. If you use persistent connections, your
  1575. application could access invalid or privileged data that were
  1576. created in a previous <acronym>PHP</acronym> request.
  1577. </para>
  1578. <para>
  1579. Currently, only Oracle, <acronym>DB2</acronym>, and the <acronym>PDO</acronym>
  1580. adapters (where specified by <acronym>PHP</acronym>) support persistence in
  1581. <classname>Zend_Db</classname>.
  1582. </para>
  1583. </note>
  1584. </sect2>
  1585. <sect2 id="zend.db.adapter.other-statements">
  1586. <title>Running Other Database Statements</title>
  1587. <para>
  1588. There might be cases in which you need to access the connection
  1589. object directly, as provided by the <acronym>PHP</acronym> database extension. Some
  1590. of these extensions may offer features that are not surfaced by
  1591. methods of <classname>Zend_Db_Adapter_Abstract</classname>.
  1592. </para>
  1593. <para>
  1594. For example, all <acronym>SQL</acronym> statements run by <classname>Zend_Db</classname>
  1595. are prepared, then executed. However, some database features are incompatible with
  1596. prepared statements. <constant>DDL</constant> statements like
  1597. <constant>CREATE</constant> and <constant>ALTER</constant> cannot be prepared in MySQL.
  1598. Also, <acronym>SQL</acronym> statements don't benefit from the <ulink
  1599. url="http://dev.mysql.com/doc/refman/5.1/en/query-cache-how.html">MySQL Query
  1600. Cache</ulink>, prior to MySQL 5.1.17.
  1601. </para>
  1602. <para>
  1603. Most <acronym>PHP</acronym> database extensions provide a method to execute
  1604. <acronym>SQL</acronym> statements without preparing them. For example, in
  1605. <acronym>PDO</acronym>, this method is <methodname>exec()</methodname>. You can access
  1606. the connection object in the <acronym>PHP</acronym> extension directly using
  1607. <methodname>getConnection()</methodname>.
  1608. </para>
  1609. <example id="zend.db.adapter.other-statements.example">
  1610. <title>Running a Non-Prepared Statement in a PDO Adapter</title>
  1611. <programlisting language="php"><![CDATA[
  1612. $result = $db->getConnection()->exec('DROP TABLE bugs');
  1613. ]]></programlisting>
  1614. </example>
  1615. <para>
  1616. Similarly, you can access other methods or properties that are
  1617. specific to <acronym>PHP</acronym> database extensions. Be aware, though, that by
  1618. doing this you might constrain your application to the interface
  1619. provided by the extension for a specific brand of <acronym>RDBMS</acronym>.
  1620. </para>
  1621. <para>
  1622. In future versions of <classname>Zend_Db</classname>, there will be opportunities to
  1623. add method entry points for functionality that is common to
  1624. the supported <acronym>PHP</acronym> database extensions. This will not affect
  1625. backward compatibility.
  1626. </para>
  1627. </sect2>
  1628. <sect2 id="zend.db.adapter.server-version">
  1629. <title>Retrieving Server Version</title>
  1630. <para>
  1631. Since release 1.7.2, you could retrieve the server version in <acronym>PHP</acronym>
  1632. syntax style to be able to use <methodname>version_compare()</methodname>. If the
  1633. information isn't available, you will receive <constant>NULL</constant>.
  1634. </para>
  1635. <example id="zend.db.adapter.server-version.example">
  1636. <title>Verifying server version before running a query</title>
  1637. <programlisting language="php"><![CDATA[
  1638. $version = $db->getServerVersion();
  1639. if (!is_null($version)) {
  1640. if (version_compare($version, '5.0.0', '>=')) {
  1641. // do something
  1642. } else {
  1643. // do something else
  1644. }
  1645. } else {
  1646. // impossible to read server version
  1647. }
  1648. ]]></programlisting>
  1649. </example>
  1650. </sect2>
  1651. <sect2 id="zend.db.adapter.adapter-notes">
  1652. <title>Notes on Specific Adapters</title>
  1653. <para>
  1654. This section lists differences between the Adapter classes of which
  1655. you should be aware.
  1656. </para>
  1657. <sect3 id="zend.db.adapter.adapter-notes.ibm-db2">
  1658. <title>IBM DB2</title>
  1659. <itemizedlist>
  1660. <listitem>
  1661. <para>
  1662. Specify this Adapter to the <methodname>factory()</methodname> method with
  1663. the name 'Db2'.
  1664. </para>
  1665. </listitem>
  1666. <listitem>
  1667. <para>
  1668. This Adapter uses the <acronym>PHP</acronym> extension
  1669. <constant>IBM_DB2</constant>.
  1670. </para>
  1671. </listitem>
  1672. <listitem>
  1673. <para>
  1674. <acronym>IBM</acronym> <acronym>DB2</acronym> supports both sequences and
  1675. auto-incrementing keys. Therefore the arguments to
  1676. <methodname>lastInsertId()</methodname> are optional. If you give
  1677. no arguments, the Adapter returns the last value
  1678. generated for an auto-increment key. If you give
  1679. arguments, the Adapter returns the last value generated
  1680. by the sequence named according to the convention
  1681. '<emphasis>table</emphasis>_<emphasis>column</emphasis>_seq'.
  1682. </para>
  1683. </listitem>
  1684. </itemizedlist>
  1685. </sect3>
  1686. <sect3 id="zend.db.adapter.adapter-notes.mysqli">
  1687. <title>MySQLi</title>
  1688. <itemizedlist>
  1689. <listitem>
  1690. <para>
  1691. Specify this Adapter to the <methodname>factory()</methodname>
  1692. method with the name 'Mysqli'.
  1693. </para>
  1694. </listitem>
  1695. <listitem>
  1696. <para>
  1697. This Adapter utilizes the <acronym>PHP</acronym> extension mysqli.
  1698. </para>
  1699. </listitem>
  1700. <listitem>
  1701. <para>
  1702. MySQL and MariaDB do not support sequences, so
  1703. <methodname>lastInsertId()</methodname> ignores its arguments and
  1704. always returns the last value generated for an
  1705. auto-increment key. The <methodname>lastSequenceId()</methodname>
  1706. method returns <constant>NULL</constant>.
  1707. </para>
  1708. </listitem>
  1709. </itemizedlist>
  1710. </sect3>
  1711. <sect3 id="zend.db.adapter.adapter-notes.oracle">
  1712. <title>Oracle</title>
  1713. <itemizedlist>
  1714. <listitem>
  1715. <para>
  1716. Specify this Adapter to the <methodname>factory()</methodname>
  1717. method with the name 'Oracle'.
  1718. </para>
  1719. </listitem>
  1720. <listitem>
  1721. <para>
  1722. This Adapter uses the <acronym>PHP</acronym> extension oci8.
  1723. </para>
  1724. </listitem>
  1725. <listitem>
  1726. <para>
  1727. Oracle does not support auto-incrementing keys, so you
  1728. should specify the name of a sequence to
  1729. <methodname>lastInsertId()</methodname> or
  1730. <methodname>lastSequenceId()</methodname>.
  1731. </para>
  1732. </listitem>
  1733. <listitem>
  1734. <para>
  1735. The Oracle extension does not support positional
  1736. parameters. You must use named parameters.
  1737. </para>
  1738. </listitem>
  1739. <listitem>
  1740. <para>
  1741. Currently the <constant>Zend_Db::CASE_FOLDING</constant> option
  1742. is not supported by the Oracle adapter. To use this
  1743. option with Oracle, you must use the <acronym>PDO</acronym>
  1744. <acronym>OCI</acronym> adapter.
  1745. </para>
  1746. </listitem>
  1747. <listitem>
  1748. <para>
  1749. By default, <acronym>LOB</acronym> fields are returned as
  1750. <acronym>OCI</acronym>-Lob objects. You could retrieve them as string for
  1751. all requests by using driver options '<property>lob_as_string</property>' or
  1752. for particular request by using
  1753. <methodname>setLobAsString(boolean)</methodname> on adapter or on statement.
  1754. </para>
  1755. </listitem>
  1756. </itemizedlist>
  1757. </sect3>
  1758. <sect3 id="zend.db.adapter.adapter-notes.sqlsrv">
  1759. <title>Microsoft SQL Server</title>
  1760. <itemizedlist>
  1761. <listitem>
  1762. <para>
  1763. Specify this Adapter to the <methodname>factory()</methodname> method with
  1764. the name 'Sqlsrv'.
  1765. </para>
  1766. </listitem>
  1767. <listitem>
  1768. <para>
  1769. This Adapter uses the <acronym>PHP</acronym> extension sqlsrv
  1770. </para>
  1771. </listitem>
  1772. <listitem>
  1773. <para>
  1774. Only Microsoft <acronym>SQL</acronym> Server 2005 or greater is supported.
  1775. </para>
  1776. </listitem>
  1777. <listitem>
  1778. <para>
  1779. Microsoft <acronym>SQL</acronym> Server does not support sequences, so
  1780. <methodname>lastInsertId()</methodname> ignores primary key argument and
  1781. returns the last value generated for an auto-increment key if a table name
  1782. is specified or a last insert query returned id. The
  1783. <methodname>lastSequenceId()</methodname> method returns
  1784. <constant>NULL</constant>.
  1785. </para>
  1786. </listitem>
  1787. <listitem>
  1788. <para>
  1789. <classname>Zend_Db_Adapter_Sqlsrv</classname> sets
  1790. <constant>QUOTED_IDENTIFIER</constant> ON immediately
  1791. after connecting to a <acronym>SQL</acronym> Server database. This makes the
  1792. driver use the standard <acronym>SQL</acronym> identifier delimiter symbol
  1793. (<emphasis>"</emphasis>) instead of the proprietary square-brackets
  1794. syntax <acronym>SQL</acronym> Server uses for delimiting identifiers.
  1795. </para>
  1796. </listitem>
  1797. <listitem>
  1798. <para>
  1799. You can specify <property>driver_options</property> as a key in the options
  1800. array. The value can be a anything from here <ulink
  1801. url="http://msdn.microsoft.com/en-us/library/cc296161(SQL.90).aspx">http://msdn.microsoft.com/en-us/library/cc296161(SQL.90).aspx</ulink>.
  1802. </para>
  1803. </listitem>
  1804. <listitem>
  1805. <para>
  1806. You can use <methodname>setTransactionIsolationLevel()</methodname> to set
  1807. isolation level for current connection. The value can be
  1808. <constant>SQLSRV_TXN_READ_UNCOMMITTED</constant>,
  1809. <constant>SQLSRV_TXN_READ_COMMITTED</constant>,
  1810. <constant>SQLSRV_TXN_REPEATABLE_READ</constant>,
  1811. <constant>SQLSRV_TXN_SNAPSHOT</constant> or
  1812. <constant>SQLSRV_TXN_SERIALIZABLE</constant>.
  1813. </para>
  1814. </listitem>
  1815. <listitem>
  1816. <para>
  1817. As of Zend Framework 1.9, the minimal supported build of the
  1818. <acronym>PHP</acronym> <acronym>SQL</acronym> Server extension from
  1819. Microsoft is 1.0.1924.0. and the <acronym>MSSQL</acronym> Server Native
  1820. Client version 9.00.3042.00.
  1821. </para>
  1822. </listitem>
  1823. </itemizedlist>
  1824. </sect3>
  1825. <sect3 id="zend.db.adapter.adapter-notes.pdo-ibm">
  1826. <title>PDO for IBM DB2 and Informix Dynamic Server (IDS)</title>
  1827. <itemizedlist>
  1828. <listitem>
  1829. <para>
  1830. Specify this Adapter to the <methodname>factory()</methodname>
  1831. method with the name '<classname>Pdo_Ibm</classname>'.
  1832. </para>
  1833. </listitem>
  1834. <listitem>
  1835. <para>
  1836. This Adapter uses the <acronym>PHP</acronym> extensions
  1837. <acronym>PDO</acronym> and <constant>PDO_IBM</constant>.
  1838. </para>
  1839. </listitem>
  1840. <listitem>
  1841. <para>
  1842. You must use at least <constant>PDO_IBM</constant> extension version 1.2.2.
  1843. If you have an earlier version of this extension, you
  1844. must upgrade the <constant>PDO_IBM</constant> extension from
  1845. <acronym>PECL</acronym>.
  1846. </para>
  1847. </listitem>
  1848. </itemizedlist>
  1849. </sect3>
  1850. <sect3 id="zend.db.adapter.adapter-notes.pdo-mssql">
  1851. <title>PDO Microsoft SQL Server</title>
  1852. <itemizedlist>
  1853. <listitem>
  1854. <para>
  1855. Specify this Adapter to the <methodname>factory()</methodname>
  1856. method with the name '<classname>Pdo_Mssql</classname>'.
  1857. </para>
  1858. </listitem>
  1859. <listitem>
  1860. <para>
  1861. This Adapter uses the <acronym>PHP</acronym> extensions pdo and pdo_dblib.
  1862. </para>
  1863. </listitem>
  1864. <listitem>
  1865. <para>
  1866. Microsoft <acronym>SQL</acronym> Server does not support sequences, so
  1867. <methodname>lastInsertId()</methodname> ignores its arguments and
  1868. always returns the last value generated for an
  1869. auto-increment key. The <methodname>lastSequenceId()</methodname>
  1870. method returns <constant>NULL</constant>.
  1871. </para>
  1872. </listitem>
  1873. <listitem>
  1874. <para>
  1875. If you are working with unicode strings in an encoding other than
  1876. <acronym>UCS</acronym>-2 (such as <acronym>UTF</acronym>-8), you may have to
  1877. perform a conversion in your application code or store the data in a binary
  1878. column. Please refer to <ulink
  1879. url="http://support.microsoft.com/kb/232580">Microsoft's Knowledge
  1880. Base</ulink> for more information.
  1881. </para>
  1882. </listitem>
  1883. <listitem>
  1884. <para>
  1885. <classname>Zend_Db_Adapter_Pdo_Mssql</classname> sets
  1886. <constant>QUOTED_IDENTIFIER</constant> ON immediately
  1887. after connecting to a <acronym>SQL</acronym> Server database. This makes the
  1888. driver use the standard <acronym>SQL</acronym> identifier delimiter symbol
  1889. (") instead of the proprietary square-brackets syntax <acronym>SQL</acronym>
  1890. Server uses for delimiting identifiers.
  1891. </para>
  1892. </listitem>
  1893. <listitem>
  1894. <para>
  1895. You can specify <property>pdoType</property> as a key in the
  1896. options array. The value can be "mssql" (the default),
  1897. "dblib", "freetds", or "sybase". This option affects
  1898. the <acronym>DSN</acronym> prefix the adapter uses when constructing the
  1899. <acronym>DSN</acronym> string. Both "freetds" and "sybase" imply a prefix
  1900. of "sybase:", which is used for the
  1901. <ulink url="http://www.freetds.org/">FreeTDS</ulink> set
  1902. of libraries.
  1903. See also
  1904. <ulink url="http://www.php.net/manual/en/ref.pdo-dblib.connection.php">
  1905. http://www.php.net/manual/en/ref.pdo-dblib.connection.php</ulink>
  1906. for more information on the <acronym>DSN</acronym> prefixes used in this
  1907. driver.
  1908. </para>
  1909. </listitem>
  1910. </itemizedlist>
  1911. </sect3>
  1912. <sect3 id="zend.db.adapter.adapter-notes.pdo-mysql">
  1913. <title>PDO MySQL</title>
  1914. <itemizedlist>
  1915. <listitem>
  1916. <para>
  1917. Specify this Adapter to the <methodname>factory()</methodname>
  1918. method with the name '<classname>Pdo_Mysql</classname>'.
  1919. </para>
  1920. </listitem>
  1921. <listitem>
  1922. <para>
  1923. This Adapter uses the <acronym>PHP</acronym> extensions pdo and pdo_mysql.
  1924. </para>
  1925. </listitem>
  1926. <listitem>
  1927. <para>
  1928. MySQL and MariaDB do not support sequences, so
  1929. <methodname>lastInsertId()</methodname> ignores its arguments and
  1930. always returns the last value generated for an
  1931. auto-increment key. The <methodname>lastSequenceId()</methodname>
  1932. method returns <constant>NULL</constant>.
  1933. </para>
  1934. </listitem>
  1935. </itemizedlist>
  1936. </sect3>
  1937. <sect3 id="zend.db.adapter.adapter-notes.pdo-oci">
  1938. <title>PDO Oracle</title>
  1939. <itemizedlist>
  1940. <listitem>
  1941. <para>
  1942. Specify this Adapter to the <methodname>factory()</methodname>
  1943. method with the name '<classname>Pdo_Oci</classname>'.
  1944. </para>
  1945. </listitem>
  1946. <listitem>
  1947. <para>
  1948. This Adapter uses the <acronym>PHP</acronym> extensions pdo and pdo_oci.
  1949. </para>
  1950. </listitem>
  1951. <listitem>
  1952. <para>
  1953. Oracle does not support auto-incrementing keys, so you
  1954. should specify the name of a sequence to
  1955. <methodname>lastInsertId()</methodname> or
  1956. <methodname>lastSequenceId()</methodname>.
  1957. </para>
  1958. </listitem>
  1959. </itemizedlist>
  1960. </sect3>
  1961. <sect3 id="zend.db.adapter.adapter-notes.pdo-pgsql">
  1962. <title>PDO PostgreSQL</title>
  1963. <itemizedlist>
  1964. <listitem>
  1965. <para>
  1966. Specify this Adapter to the <methodname>factory()</methodname>
  1967. method with the name '<classname>Pdo_Pgsql</classname>'.
  1968. </para>
  1969. </listitem>
  1970. <listitem>
  1971. <para>
  1972. This Adapter uses the <acronym>PHP</acronym> extensions pdo and pdo_pgsql.
  1973. </para>
  1974. </listitem>
  1975. <listitem>
  1976. <para>
  1977. PostgreSQL supports both sequences and auto-incrementing
  1978. keys. Therefore the arguments to
  1979. <methodname>lastInsertId()</methodname> are optional. If you give
  1980. no arguments, the Adapter returns the last value
  1981. generated for an auto-increment key. If you give
  1982. arguments, the Adapter returns the last value generated
  1983. by the sequence named according to the convention
  1984. '<emphasis>table</emphasis>_<emphasis>column</emphasis>_seq'.
  1985. </para>
  1986. </listitem>
  1987. </itemizedlist>
  1988. </sect3>
  1989. <sect3 id="zend.db.adapter.adapter-notes.pdo-sqlite">
  1990. <title>PDO SQLite</title>
  1991. <itemizedlist>
  1992. <listitem>
  1993. <para>
  1994. Specify this Adapter to the <methodname>factory()</methodname>
  1995. method with the name '<classname>Pdo_Sqlite</classname>'.
  1996. </para>
  1997. </listitem>
  1998. <listitem>
  1999. <para>
  2000. This Adapter uses the <acronym>PHP</acronym> extensions pdo and pdo_sqlite.
  2001. </para>
  2002. </listitem>
  2003. <listitem>
  2004. <para>
  2005. SQLite does not support sequences, so
  2006. <methodname>lastInsertId()</methodname> ignores its arguments and
  2007. always returns the last value generated for an
  2008. auto-increment key. The <methodname>lastSequenceId()</methodname>
  2009. method returns <constant>NULL</constant>.
  2010. </para>
  2011. </listitem>
  2012. <listitem>
  2013. <para>
  2014. To connect to an SQLite2 database, specify
  2015. <command>'sqlite2' => true</command> in the array of
  2016. parameters when creating an instance of the
  2017. <classname>Pdo_Sqlite</classname> Adapter.
  2018. </para>
  2019. </listitem>
  2020. <listitem>
  2021. <para>
  2022. To connect to an in-memory SQLite database,
  2023. specify <command>'dbname' => ':memory:'</command> in the
  2024. array of parameters when creating an instance of
  2025. the <classname>Pdo_Sqlite</classname> Adapter.
  2026. </para>
  2027. </listitem>
  2028. <listitem>
  2029. <para>
  2030. Older versions of the SQLite driver for <acronym>PHP</acronym> do not seem
  2031. to support the <acronym>PRAGMA</acronym> commands necessary to ensure that
  2032. short column names are used in result sets. If you
  2033. have problems that your result sets are returned with
  2034. keys of the form "tablename.columnname" when you do a
  2035. join query, then you should upgrade to the current
  2036. version of <acronym>PHP</acronym>.
  2037. </para>
  2038. </listitem>
  2039. </itemizedlist>
  2040. </sect3>
  2041. <sect3 id="zend.db.adapter.adapter-notes.firebird">
  2042. <title>Firebird (Interbase)</title>
  2043. <itemizedlist>
  2044. <listitem>
  2045. <para>
  2046. This Adapter uses the <acronym>PHP</acronym> extension php_interbase.
  2047. </para>
  2048. </listitem>
  2049. <listitem>
  2050. <para>
  2051. Firebird (Interbase) does not support auto-incrementing
  2052. keys, so you should specify the name of a sequence to
  2053. <methodname>lastInsertId()</methodname> or
  2054. <methodname>lastSequenceId()</methodname>.
  2055. </para>
  2056. </listitem>
  2057. <listitem>
  2058. <para>
  2059. Currently the <constant>Zend_Db::CASE_FOLDING</constant> option
  2060. is not supported by the Firebird (Interbase) adapter.
  2061. Unquoted identifiers are automatically returned in
  2062. upper case.
  2063. </para>
  2064. </listitem>
  2065. <listitem>
  2066. <para>Adapter name is <classname>ZendX_Db_Adapter_Firebird</classname>.</para>
  2067. <para>
  2068. Remember to use the param adapterNamespace with value
  2069. <classname>ZendX_Db_Adapter</classname>.
  2070. </para>
  2071. <para>
  2072. We recommend to update the <filename>gds32.dll</filename> (or linux
  2073. equivalent) bundled with <acronym>PHP</acronym>, to the same version of the
  2074. server. For Firebird the equivalent <filename>gds32.dll</filename> is
  2075. <filename>fbclient.dll</filename>.
  2076. </para>
  2077. <para>
  2078. By default all identifiers (tables names, fields) are returned in upper
  2079. case.
  2080. </para>
  2081. </listitem>
  2082. </itemizedlist>
  2083. </sect3>
  2084. </sect2>
  2085. </sect1>
  2086. <!--
  2087. vim:se ts=4 sw=4 et:
  2088. -->