<?xml version="1.0" encoding="UTF-8"?>
<wiki>
  <body>&lt;h2&gt;Usage&lt;/h2&gt;
&lt;p&gt;&lt;b&gt;Example 1&lt;/b&gt;: creating a specific connector type&lt;br /&gt;
&lt;pre&gt;&lt;br /&gt;
&lt;code&gt;
class Connector_MyDBType implements Connector {
    // Implement all methods in the Connector interface here
}
&lt;/code&gt;&lt;br /&gt;
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Example 2&lt;/b&gt;: using a standalone connector&lt;br /&gt;
&lt;pre&gt;&lt;br /&gt;
&lt;code&gt;
$connector = new Connector_MyDBType();
$connector-&amp;gt;connect('mydbtype://user:pass@host:port');
if (!$connector-&amp;gt;query('SELECT * FROM table')) {
    echo &quot;The query failed!&quot;;
    exit;
}
if (!$connector-&amp;gt;affectedrows()) {
    echo &quot;No rows were found!&quot;;
    exit;
}
while ($row = $connector-&amp;gt;fetchrow()) {
    var_dump($row); // Dumps each result set row hash
}
&lt;/code&gt;&lt;br /&gt;
&lt;/pre&gt;&lt;/p&gt;
&lt;h2&gt;Constants&lt;/h2&gt;
&lt;p&gt;&lt;code&gt;RS_HASH&lt;/code&gt; &amp;#8212; indicates each row in a result set should be a hash (associative array) of key/value pairs&lt;/p&gt;
&lt;p&gt;&lt;code&gt;RS_NUM&lt;/code&gt; &amp;#8212; indicates each row in a result set should be a numerically indexed array&lt;/p&gt;
&lt;p&gt;&lt;code&gt;RS_BOTH&lt;/code&gt; &amp;#8212; indicates each row in a result should should return each field both as a key/value pair and a numerical index (combines formats of RS_HASH and RS_NUM)&lt;/p&gt;
&lt;h2&gt;Methods&lt;/h2&gt;
&lt;h3&gt;Connecting&lt;/h3&gt;
&lt;div class=&quot;method&quot;&gt;
&lt;p&gt;&lt;b&gt;connect&lt;/b&gt;&lt;br /&gt;
&lt;small&gt;public &lt;b&gt;connect&lt;/b&gt;($connection_string)&lt;/small&gt;&lt;br /&gt;
&lt;div style=&quot;margin-left:20px;&quot;&gt;&lt;br /&gt;
Connects to a database server&lt;br /&gt;
Opens a connection to the given database server using the (optional) username and password&lt;br /&gt;
param  {str}  Connection string in standard &lt;span class=&quot;caps&quot;&gt;PHP&lt;/span&gt; parse_url format&lt;br /&gt;
return {bool} Success or failure in connection&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;method&quot;&gt;
&lt;p&gt;&lt;b&gt;disconnect&lt;/b&gt;&lt;br /&gt;
&lt;small&gt;public &lt;b&gt;disconnect&lt;/b&gt;()&lt;/small&gt;&lt;br /&gt;
&lt;div style=&quot;margin-left:20px;&quot;&gt;&lt;br /&gt;
Closes a connection&lt;br /&gt;
return {bool} Success or failure&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;method&quot;&gt;
&lt;p&gt;&lt;b&gt;useDB&lt;/b&gt;&lt;br /&gt;
&lt;small&gt;public &lt;b&gt;useDB&lt;/b&gt;($db)&lt;/small&gt;&lt;br /&gt;
&lt;div style=&quot;margin-left:20px;&quot;&gt;&lt;br /&gt;
Selects a database to use on a host&lt;br /&gt;
param  {str}  Database name&lt;br /&gt;
return {bool} Success or failure&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;h3&gt;Query Building&lt;/h3&gt;
&lt;div class=&quot;method&quot;&gt;
&lt;p&gt;&lt;b&gt;query&lt;/b&gt;&lt;br /&gt;
&lt;small&gt;public &lt;b&gt;query&lt;/b&gt;($sql)&lt;/small&gt;&lt;br /&gt;
&lt;div style=&quot;margin-left:20px;&quot;&gt;&lt;br /&gt;
Sends a &lt;span class=&quot;caps&quot;&gt;SQL&lt;/span&gt; query to the database&lt;br /&gt;
param  {str}  &lt;span class=&quot;caps&quot;&gt;SQL&lt;/span&gt; statement to run&lt;br /&gt;
return {bool} Success or failure of statement&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;h3&gt;Result Set Manipulation&lt;/h3&gt;
&lt;div class=&quot;method&quot;&gt;
&lt;p&gt;&lt;b&gt;affectedrows&lt;/b&gt;&lt;br /&gt;
&lt;small&gt;public &lt;b&gt;affectedrows&lt;/b&gt;()&lt;/small&gt;&lt;br /&gt;
&lt;div style=&quot;margin-left:20px;&quot;&gt;&lt;br /&gt;
Gets the number of affected rows in a query&lt;br /&gt;
For &lt;span class=&quot;caps&quot;&gt;SELECT&lt;/span&gt; queries, returns the number of found rows. For &lt;span class=&quot;caps&quot;&gt;INSERT&lt;/span&gt;/&lt;span class=&quot;caps&quot;&gt;UPDATE&lt;/span&gt;/&lt;span class=&quot;caps&quot;&gt;DELETE&lt;/span&gt;, returns the number of affected rows.&lt;br /&gt;
return {int} Number of found or affected rows&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;method&quot;&gt;
&lt;p&gt;&lt;b&gt;fetchrowset&lt;/b&gt;&lt;br /&gt;
&lt;small&gt;public &lt;b&gt;fetchrowset&lt;/b&gt;([$type])&lt;/small&gt;&lt;br /&gt;
&lt;div style=&quot;margin-left:20px;&quot;&gt;&lt;br /&gt;
Gets all the rows returned in a &lt;span class=&quot;caps&quot;&gt;SELECT&lt;/span&gt; query&lt;br /&gt;
Returns all the rows in a &lt;span class=&quot;caps&quot;&gt;SELECT&lt;/span&gt; query resultset as an array. Each row can be returned as a hash (default) by passing in the RS_HASH constant or as a numerically indexed array by passing in the RS_NUM constant, or both at once with the RS_BOTH constant. If no rows are found, returns &lt;span class=&quot;caps&quot;&gt;FALSE&lt;/span&gt;.&lt;br /&gt;
return {array}&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;method&quot;&gt;
&lt;p&gt;&lt;b&gt;fetchrow&lt;/b&gt;&lt;br /&gt;
&lt;small&gt;public &lt;b&gt;fetchrow&lt;/b&gt;([$type])&lt;/small&gt;&lt;br /&gt;
&lt;div style=&quot;margin-left:20px;&quot;&gt;&lt;br /&gt;
Gets the current result set row&lt;br /&gt;
Returns the current result set row and increments the result set pointer. When no more rows are found, returns &lt;span class=&quot;caps&quot;&gt;FALSE&lt;/span&gt;. A row can be returned as a hash (default) by passing in the RS_HASH constant or as a numerically indexed array by passing in the RS_NUM constant, or both at once with the RS_BOTH constant. This method is best used when only one row is expected or in using a while loop to pull down one row at a time.&lt;br /&gt;
return {array} Current row in requested format&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;method&quot;&gt;
&lt;p&gt;&lt;b&gt;fetchfield&lt;/b&gt;&lt;br /&gt;
&lt;small&gt;public &lt;b&gt;fetchfield&lt;/b&gt;($field)&lt;/small&gt;&lt;br /&gt;
&lt;div style=&quot;margin-left:20px;&quot;&gt;&lt;br /&gt;
Gets a field&amp;#8217;s value in the current result set row&lt;br /&gt;
Returns the value of a given field in the current result set row and increments the result set pointer. When no more rows are found, returns &lt;span class=&quot;caps&quot;&gt;FALSE&lt;/span&gt;. If the field does not exist, an exception is thrown. This method is best used when only one row is expected or in using a while loop to pull down one row at a time.&lt;br /&gt;
return {array}&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;</body>
  <created-at type="datetime">2008-03-27T22:34:27-07:00</created-at>
  <id type="integer">6336</id>
  <permalink>connector-interface</permalink>
  <repository-id type="integer">1902</repository-id>
  <title>Connector Interface</title>
  <updated-at type="datetime">2008-04-03T14:44:30-07:00</updated-at>
  <user-id type="integer">1816</user-id>
</wiki>
