<?php
/**
* Entier Studio
*
* LICENSE
*
* Copyright 2006 Entier Studio team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @package entier.framework
* @copyright Copyright (c) 2006 Entier Studio team. All rights reserved.
* @version $Id: mysql.database.php 81 2008-01-17 23:08:21Z yannromefort $
*/
//-----------------------------------------------------------------------------
// namespace
if (!defined("DefMySQLDatabase")) {
//-------------------------------------------------------------------------
// Define
define("DefMySQLDatabase", "1");
//-------------------------------------------------------------------------
// Include
@require_once (FRAMEWORK_DIR . "database.php");
@require_once (FRAMEWORK_DIR . "mysql.datasource.php");
//-------------------------------------------------------------------------
// Class
class MySQLDatabase extends Database {
//---------------------------------------------------------------------
// Attributes
//---------------------------------------------------------------------
// Constructor
/**
* constructor
*/
/**
* Data source constructor
* @param string host
* @param string port
* @param string user
* @param string pass
* @param string base
*/
function MySQLDatabase($hostName = "", $hostPort = 0, $userName = "", $passWord = "", $dataBase = "") {
$this->m_Source = new MySQLDataSource($hostName, $hostPort, $userName, $passWord, $dataBase);
}
//---------------------------------------------------------------------
// Methods
/**
* Execute a select query
*
* @param string query string
* @return DataList
*/
function select($query = "") {
//
$querySql = @urldecode($query);
if (@preg_match("/^([a-z]+)\s.*/i", $querySql, $regs) == false) return (NULL);
//
$queryCmd = @strtoupper($regs[1]);
if ($queryCmd != "SELECT") return (NULL);
//
$resultId = false;
$resultId = $this->m_Source->executeQuery($querySql);
if (ResultId == false) return (NULL);
//
$dataList = new DataList();
while ($row = $this->m_Source->fetchDataRow($resultId)) {
$dataList->set_row_values($row);
}
$this->m_Source->freeStatement($resultId);
//
return ($dataList);
}
};
// Class
//-------------------------------------------------------------------------
}
// namespace
//-----------------------------------------------------------------------------
?>