<?php
/*******************************************************************
* DatabaseTestMsSql.php
* Copyright (C) 2006 Midnight Coders, LLC
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* The software is licensed under the GNU General Public License (GPL)
* For details, see http://www.gnu.org/licenses/gpl.txt.
********************************************************************/
class DatabaseTestMySql
{
public function getCustomers($rowsToGet)
{
if($rowsToGet > -1)
return $this->executeSql("select * from customers LIMIT $rowsToGet");
return $this->getCustomersTable();
}
public function getCustomersMultiTable()
{
$resultSet = $this->executeSql("select * from customers");
$resultArr = array();
while($row = mysql_fetch_object($resultSet))
$resultArr[] = $row;
return array($resultArr,$resultArr);
}
public function executeSql($sql)
{
$server="localhost:3306";
$username="flexuser";
$password="password";
$sqlconnect=mysql_connect($server, $username, $password);
//mysql_query("SET NAMES utf8");
if( !$sqlconnect )
throw new Exception( "cannot connect to mysql database" );
if( !mysql_select_db('northwind') )
throw new Exception( "cannot select northwind database" );
return mysql_query($sql);
}
public function getCustomersTable()
{
return $this->executeSql("select * from customers");
}
}
?>