Location: PHPKode > scripts > OoMySql > mysql.class.html
<html>
<head>
  <title>OoMySql Classes</title>
  <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-15">
  <link rel="stylesheet" type="text/css" href="docstyle.css">
</head>
<body text="black" link="#0000A0">
<table cellspacing="0" cellpadding="0" border="0" width="100%">
	<tr>
		<td class="pageHeader">MySql Baseclass</td>
	</tr>
</table>
<table cellspacing="0" cellpadding="0" border="0">
	<tr>
		<td class="headerSubLink">
			<a href="#constructor">constructor</a>
		</td>
		<td class="headerSubLink">
			<a href="#public">public
		</td>
		<td class="headerSubRightEnd">
			<a href="#private">_private
		</td>
	</tr>
</table>
<table cellspacing="0" cellpadding="0" border="0" width="100%">
	<tr>
		<td class="className">
			Public :: MySql
		</td>
	</tr>
	<tr>
		<td class="textNorm">Subclasses:
			<ul>
				<li><a href="mysqldb.class.html">MySqldb</a></li>
				<li><a href="#intro">MySqltable</a></li>
			</ul>
			optional helper classes:
			<ul>
				<li><a href="#intro">Logger Class</a></li>
					<ul>
						<li><a href="#intro">Exception Class</a></li>
					</ul>
				</ul>
		</td>
	</tr>
	<tr>
		<td height="10">&nbsp;</td>
	</tr>
	<tr>
		<td class="seperatorLine"></td>
	</tr>
	<tr>
		<td height="10">&nbsp;</td>
	</tr>
	<tr>
		<td class="textNorm">
			<p>
				Baseclass to access a MySql Database Server.	This class also comes with a handy logging mechanism (which will need the optional exception class).
				The usage of this class should be fairly obvious. Here some examples:
				<pre>
	// create a new sql object  - Database host, Database user, Database pass, use logger class
	$sql = new MySql("dbhost","dbuser","dbpass",true);
	// get some info on mysql server
	$server_info = $sql->getServerInfo();
	// create a database and receive reference to new databaseObj
	$dbObject = &$sql->createDB('testDatabase');
				</pre>
				If no connection could be established the occured error will automatically be stored in MySql->error_msg. If logging was turned on,
				a log entry will also be added.<br><br>
				To check for an existing DB connection you can call <span class="code">MySql->isConnected();</span> which returns a bool.<br><br>
				To query the database you can call <span class="code">MySql->query("your sql query");</span>, at the moment only returning a MySql resource identifier.
			</p>
		</td>
	</tr>
</table>
<table cellspacing="0" cellpadding="0" border="0" width="100%">
	<tr>
		<td height="10">&nbsp;</td>
	</tr>
	<tr>
		<td class="subHeading" colspan="2">
			<a name="constructor"></a>constructor
		</td>
	</tr>
	<tr>
		<td class="variable">mysql object
		</td>
		<td class="keyword" align="left">
			= MySql(STRING $server, STRING $user, STRING $password, BOOL $use_log)
		</td>
	</tr>
	<tr>
		<td></td>
		<td class="textNorm" align="left">
			create a new MySql object and connect to database server
		</td>
	</tr>
	<tr>
		<td height="10">&nbsp;</td>
	</tr>
	<tr>
		<td class="subHeading" colspan="2">
			<a name="public">public methods</a>
		</td>
	</tr>
	<tr>
		<td class="variable"><a name="createDB"></a><a href="mysqldb.class.html">MySqlDB Object Reference</a></td>
		<td class="keyword" align="left">
			= &MySql->createDB(STRING $database);
		</td>
	</tr>
	<tr>
		<td></td>
		<td class="textNorm" align="left">
			create a new database and receive a reference to access it
		</td>
	</tr>
	<tr>
		<td class="variable"><a name="getAffectedRows"></a>INT
		</td>
		<td class="keyword" align="left">
			= MySql->getAffectedRows();
		</td>
	</tr>
	<tr>
		<td></td>
		<td class="textNorm" align="left">
			get number of affected rows by last sql statement
		</td>
	</tr>
	<tr>
		<td class="variable"><a name="getClientInfo"></a>STRING
		</td>
		<td class="keyword" align="left">
			= MySql->getClientInfo();
		</td>
	</tr>
	<tr>
		<td></td>
		<td class="textNorm" align="left">
			get number of affected rows by last sql statement
		</td>
	</tr>
	<tr>
		<td class="variable"><a name="getErrNo"></a>INT
		</td>
		<td class="keyword" align="left">
			= MySql->getErrNo();
		</td>
	</tr>
	<tr>
		<td></td>
		<td class="textNorm" align="left">
			get error number or 0 if no error occurred
		</td>
	</tr>
		<tr>
		<td class="variable"><a name="getHostInfo"></a>STRING
		</td>
		<td class="keyword" align="left">
			= MySql->getHostInfo();	
		</td>
	</tr>
	<tr>
		<td></td>
		<td class="textNorm" align="left">
			get information about current connection to server incl. server host name
		</td>
	</tr>
	<tr>
		<td class="variable"><a name="getMySqlInfo"></a>STRING
		</td>
		<td class="keyword" align="left">
			= MySql->getMySqlInfo();
		</td>
	</tr>
	<tr>
		<td></td>
		<td class="textNorm" align="left">
			get information about last sql query
		</td>
	</tr>
	<tr>
		<td class="variable"><a name="getNumFields"></a>INT
		</td>
		<td class="keyword" align="left">
			= MySql->getNumFields();
		</td>
	</tr>
	<tr>
		<td></td>
		<td class="textNorm" align="left">
			get number of fields in the result set of last sql statement
		</td>
	</tr>
	<tr>
		<td class="variable"><a name="getNumRows"></a>INT</td>
		<td class="keyword" align="left">
			= MySql->getNumRows();
		</td>
	</tr>
	<tr>
		<td></td>
		<td class="textNorm" align="left">
			get number of rows in the result set of last sql statement
		</td>
	</tr>
	<tr>
		<td class="variable"><a name="getServerInfo"></a>STRING</td>
		<td class="keyword" align="left">
			= MySql->getServerInfo();
		</td>
	</tr>
	<tr>
		<td></td>
		<td class="textNorm" align="left">
			get server version
		</td>
	</tr>
	<tr>
		<td class="variable"><a name="getStat"></a>STRING</td>
		<td class="keyword" align="left">
			= MySql->getStat();
		</td>
	</tr>
	<tr>
		<td></td>
		<td class="textNorm" align="left">
			get current server status
		</td>
	</tr>
	<tr>
		<td class="variable"><a name="insertId"></a>INT</td>
		<td class="keyword" align="left">
			= MySql->insertId();
		</td>
	</tr>
	<tr>
		<td></td>
		<td class="textNorm" align="left">
			get ID generated from the previous INSERT operation 
		</td>
	</tr>
	<tr>
		<td class="variable"><a name="isConnected"></a>BOOL</td>
		<td class="keyword" align="left">
			= MySql->isConnected();
		</td>
	</tr>
	<tr>
		<td></td>
		<td class="textNorm" align="left">
			get server connection status
		</td>
	</tr>
	<tr>
		<td class="variable"><a name="listDBs"></a>RESOURCE IDENTIFIER</td>
		<td class="keyword" align="left">
			= MySql->listDBs();
		</td>
	</tr>
	<tr>
		<td></td>
		<td class="textNorm" align="left">
			get list of all databases accessible by the current user
		</td>
	</tr>
	<tr>
		<td class="variable"><a name="selectDB"></a><a href="mysqldb.class.html">MySqlDB Object Reference</a></td>
		<td class="keyword" align="left">
			= &MySql->selectDB(STRING $database);
		</td>
	</tr>
	<tr>
		<td></td>
		<td class="textNorm" align="left">
			select a database and create a new database object
		</td>
	</tr>
	<tr>
		<td class="variable"><a name="query"></a>RESOURCE IDENTIFIER </td>
		<td class="keyword" align="left">
			= MySql->query(STRING $query);
		</td>
	</tr>
	<tr>
		<td></td>
		<td class="textNorm" align="left">
			send a sql statment to server 
		</td>
	</tr>
	<tr>
		<td class="variable"><a name="listTables"></a>RESOURCE IDENTIFIER </td>
		<td class="keyword" align="left">
			= MySql->listTables(STRING $database);
		</td>
	</tr>
	<tr>
		<td></td>
		<td class="textNorm" align="left">
			get a list of all tables accessible by the current user
		</td>
	</tr>
	<tr>
		<td class="pageFooter" colspan="2">&nbsp;</td>
	</tr>
</table>
</body>
</html>
Return current item: OoMySql