Location: PHPKode > scripts > phpMysqlConnection > phpmysqlconnection/phpMysqlConnection.html
<html>
 <head>
  <title>phpMysqlConnection</title>
  <style>
   body{
    font-family: sans-serif;
    background-color: #ffffff;
    font-size: 75%;
    color: #000000;
   }
   h1{
    font-family: sans-serif;
    font-size: 150%;
    color: #0000cc;
    font-weight: bold;
    background-color: #f0f0f0;
   }
   h3{
    font-family: sans-serif;
    font-size: 110%;
    font-weight: bold;
    text-decoration: underline;
    color: #0000cc;
   }
   li{
    font-family: sans-serif;
    color: #666666;
   }
   .codeexample{
    font-family: sans-serif;
    font-weight: normal;
    font-size: 90%;
    color: #999999;
   }
   .classname{
    font-family: sans-serif;
    font-weight: bold;
    color: #006600;
   }
   .bigclassname{
    font-family: sans-serif;
    font-weight: bold;
    font-size: 175%;
    color: #006600;
   }
   .updated{
    font-family: sans-serif;
    color: #cc0000;
    font-size: 110%;
   }
   .footnote{
    font-family: sans-serif;
    color: #006600;
   }
   .normaltext{
    font-family: sans-serif;
    font-size: 100%;
    color: #000000;
    font-weight: normal;
    text-transform: none;
    text-decoration: none;
   }
  </style>
 </head>
 
 <body>
<span class="bigclassname">phpMySqlConnection</span>
<p class="updated">Last modified: 7/12/2002 3:32PM GMT-6:00</p>

<p><span class="classname">phpMySqlConnection</span> is a class that helps use the mysql_* functions of PHP with a friendly interface and a rich feature set. The functions are named with a slightly less difficult way to memorize, plus many of the methods in this class offer a quick way to do related calls to perform your task. Below are brief descriptions of each method included within the class.</p>

<h1>phpMySqlConnection</h1>
<p class="codeexample">phpMySqlConnection ( [ $user [ ,$pass [ ,$host [ ,$port [ ,$socket_path ]  ]  ]  ]  ] )</p>
<p>This is the class constructor. On success you will have a new object that will allow you use the methods & variables of this class. It attempts to log into $host through $port / $socket_path using $user and $pass. Returns an error message in case of a failure, otherwise returns the integer 1.</p>

<h1>GetDatabases</h1>
<p class="codeexample">GetDatabases ( )</p>
<p>Get a list of the available databases on the current server. On success an array indexed by number of the databases available is returned. On success, an array of database names that the user has access to is returned. Else returns an error string.</p>

<h1>CreateDB</h1>
<p class="codeexample">CreateDB ( $database)</p>
<p>Create a database named $database on the server. On success returns the integer 1, else returns an error string. Also sets $obj->a_rows, which is the output of mysql_affected_rows ( ).</p>

<h1>DropDB</h1>
<p class="codeexample">DropDB ( $database)</p>
<p>Drop the database named $database from the server. Careful, this deletes all the information within the database; this is not what you'd use for a backup! On success returns the integer 1, else returns an error string. Also sets $obj->a_rows, which is the output of mysql_affected_rows ( ).</p>

<h1>CopyDB</h1>
<p class="codeexample">CopyDB ( $database, [ $dest_db [ ,$drop_tables [ ,$dest_host [ ,$dest_user [ ,$dest_pass [ ,$dest_port [ ,$dest_socket_path ]  ]  ]  ]  ]  ]  ] )</p>
<p>This function allows you to copy the database named $database to one named $dest_db on $dest_host:$dest_port using $dest_user / $dest_pass over $dest_socket. Setting $drop_tables to 1 will cause the database to overwrite the target if it exists. On success returns the integer 1, else returns an error string.</p>

<h1>CopyTable</h1>
<p class="codeexample">CopyTable ( $table,$dest_table,$database,$dest_db, [ $drop_table [ ,$conn_id [ ,$dest_host [ ,$dest_user [ ,$dest_pass [ ,$dest_port [ ,$dest_socket_path ]  ]  ]  ]  ]  ]  ] )</p>
<p>This function allows you to copy the table named $table to one named $dest_table in $dest_db on $dest_host:$dest_port using $dest_user / $dest_pass over $dest_socket. Setting $drop_tables to 1 will cause the database to overwrite the target if it exists. On success returns the integer 1, else returns an error string.</p>

<h1>SelectDB</h1>
<p class="codeexample">SelectDB ( $db)</p>
<p>Select or change your working database to $db. On success returns the integer 1, else returns an error string.</p>

<h1>GetTableList</h1>
<p class="codeexample">GetTableList ( )</p>
<p>Get a list of the available tables in the current working database. On success returns an array of table names that the user can access, else returns an error string.</p>

<h1>GetFieldList</h1>
<p class="codeexample">GetFieldList ( $tbl_name)</p>
<p>Get a list of the fields names in the table named $tbl_name of the current database. On success returns an array of the field names of the table, else returns an error string.</p>

<h1>Delete</h1>
<p class="codeexample">Delete ( $query)</p>
<p>Execute a deletion query. On success returns the integer 1, else returns an error string. Also sets $obj->a_rows, which is the output of mysql_affected_rows ( ).</p>

<h1>Update</h1>
<p class="codeexample">Update ( $query)</p>
<p>Execute an update query.  On success returns the integer 1, else returns an error string. Also sets $obj->a_rows, which is the output of mysql_affected_rows ( ).</p>

<h1>Insert</h1>
<p class="codeexample">Insert ( $query)</p>
<p>Execute an insertion query. On success returns the integer 1, else returns an error string. Also sets $obj->a_rows, which is the output of mysql_affected_rows ( ).</p>

<h1>InsertID</h1>
<p class="codeexample">InsertID ( )</p>
<p>Get last insert id from an auto_incremented field. Returns the id on success, or an error string on failure.</p>

<h1>Query</h1>
<p class="codeexample">Query ( $query)</p>
<p>Execute a query that may return more than one row. On success returns the integer 1, else returns an error string.</p>

<h1>GetRow</h1>
<p class="codeexample">GetRow ( $row)</p>
<p>Get row number $row of data from a multiple row query. This is useful when using loops to retrieve data. On success returns the integer 1, else returns an error string. Also sets the $obj->data array indexed by number and field name with the result.</p>

<h1>QueryRow</h1>
<p class="codeexample">QueryRow ( $query)</p>
<p>Execute a query that returns only one row. On success returns an array containing the data indexed by column number and field name, else returns an error string. Also sets the $obj->data array indexed by number and field name with the result.</p>

<h1>QueryItem</h1>
<p class="codeexample">QueryItem ( $query)</p>
<p>Execute a query that returns only one element. On success returns the value queried, else returns an error string. Also sets the $obj->data array indexed by number and field name with the result.</p>

<h1>XML_DataOutput</h1>
<p class="codeexample">QueryItem ( $query [ ,array ( 'dataset_tag', 'recordset_tag' ) )</p>
<p>Get an XML representation of the resultant recordset data. Returns the XML data including the header, sets $this->data without the header (XML tags only).</p>

<h1>Exists</h1>
<p class="codeexample">Exists ( $query)</p>
<p>Check if a query returns a result. Returns TRUE on existance, or FALSE on non-existance. Also sets the other class elements the same way that Query ( ) does.</p>

<h1>GetSetList</h1>
<p class="codeexample">GetSetList ( $table,$field)</p>
<p>Andrew Collington <hide@address.com> - Sets the $obj->data array indexed by number and field name with its value.</p>

<h1>GetEnumList</h1>
<p class="codeexample">GetEnumList ( $table,$field)</p>
<p>Andrew Collington <hide@address.com> - Sets the $obj->data array indexed by enum element name with its value.</p>

<h1>errorMessage</h1>
<p class="codeexample">mysql_ErrorMsg ( $msg)</p>
<p>Used within the class to return the $msg along with the output of mysql_error ( ).</p>

<h1>GETTING HELP</h1>
As of 2002-06-30, there is a bulletin board for phpMysqkConnection located at <a href="http://www.koivi.com/php/" target="forum">http://www.koivi.com/php/</a>.

<h3>Version 1.5.9</h3>
<ul>
 <li>Fixed bug in Query function that didn't reset the number of rows</li>
</ul>

<h3>Version 1.5.8</h3>
<ul>
 <li>Added XML_DataOutput</li>
 <li>Miscellaneous code clean-ups</li>
</ul>

<h3>Version 1.5</h3>
<ul>
 <li>changed to return error strings instead of exiting execution</li>
</ul>

<h3>TODO List</h3>
<ul>
 <li>Suggestions welcome: mail to <a href="mailto:hide@address.com?subject=phpMySqlConnection: Request">hide@address.com</a> with subject of "phpMySqlConnection: Request"
</ul>

</body>
</html>
Return current item: phpMysqlConnection