cvs: peardoc /en/package/database/mdb2 intro-connect.xml

From: Date: Sun, 02 Jul 2006 19:45:29 +0000
Subject: cvs: peardoc /en/package/database/mdb2 intro-connect.xml
Groups: php.pear.doc 
Request: Send a blank email to pear-doc+get-8127@lists.php.net to get a copy of this message
lsmith Sun Jul 2 19:45:29 2006 UTC Modified files: /peardoc/en/package/database/mdb2 intro-connect.xml Log: - added some basic information about the differences of factory(), connect() and singleton() (Bug #8099) http://cvs.php.net/viewvc.cgi/peardoc/en/package/database/mdb2/intro-connect.xml?r1=1.3&r2=1.4&diff_format=u Index: peardoc/en/package/database/mdb2/intro-connect.xml diff -u peardoc/en/package/database/mdb2/intro-connect.xml:1.3 peardoc/en/package/database/mdb2/intro-connect.xml:1.4 --- peardoc/en/package/database/mdb2/intro-connect.xml:1.3 Fri May 5 11:57:32 2006 +++ peardoc/en/package/database/mdb2/intro-connect.xml Sun Jul 2 19:45:28 2006 @@ -1,8 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1" ?> -<!-- $Revision: 1.3 $ --> - -<!-- add information on the following methods: -factory(), singleton() --> +<!-- $Revision: 1.4 $ --> <refentry id="package.database.mdb2.intro-connect"> <refnamediv> @@ -15,7 +12,9 @@ <para> To connect to a database you have to use the function <ulink url="http://pear.php.net/package/MDB2/docs/latest/MDB2/MDB2.html#methodfactory"> - <function>factory</function></ulink>, which requires a valid + <function>factory</function></ulink>, <ulink url="http://pear.php.net/package/MDB2/docs/latest/MDB2/MDB2.html#methodconnect"> + <function>connect</function></ulink> or <ulink url="http://pear.php.net/package/MDB2/docs/latest/MDB2/MDB2.html#methodsingleton"> + <function>singleton</function></ulink>, which require a valid <link linkend="package.database.mdb2.intro-dsn">DSN</link> as the first parameter. This parameter can either be a string or an array. If using an array, the array used gets merged with the @@ -75,7 +74,7 @@ 'result_buffering' => false, ); -$mdb2 =& MDB2::connect($dsn, $options); +$mdb2 =& MDB2::factory($dsn, $options); if (PEAR::isError($mdb2)) { die($mdb2->getMessage()); } @@ -108,6 +107,8 @@ 'portability' => MDB2_PORTABILITY_ALL, ); +// uses MDB2::factory() to create the instance +// and also attempts to connect to the host $mdb2 =& MDB2::connect($dsn, $options); if (PEAR::isError($mdb2)) { die($mdb2->getMessage()); @@ -167,7 +168,9 @@ 'ssl' => true, ); -$mdb2 =& MDB2::connect($dsn, $options); +// gets an existing instance with the same DSN +// otherwise create a new instance using MDB2::factory() +$mdb2 =& MDB2::singleton($dsn, $options); if (PEAR::isError($mdb2)) { die($mdb2->getMessage()); } @@ -189,7 +192,7 @@ 'portability' => MDB2_PORTABILITY_ALL, ); -$mdb2 =& MDB2::connect($dsn, $options); +$mdb2 =& MDB2::factory($dsn, $options); if (PEAR::isError($mdb2)) { die($mdb2->getMessage()); }

« previous php.pear.doc (#8127) next »