--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/punbb/include/enano_dbal.php Thu Jul 12 15:00:35 2007 -0400
@@ -0,0 +1,170 @@
+<?php
+/***********************************************************************
+
+ Copyright (C) 2002-2005 Dan Fuhry (dan@enanocms.org)
+
+ This file is part of the PunBB to Enano compatibility layer. No part
+ of this file is included with any official PunBB distribution.
+
+ PunBB is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 2 of the License,
+ or (at your option) any later version.
+
+ PunBB is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ MA 02111-1307 USA
+
+************************************************************************/
+
+/**
+ * A compatibility layer to allow PunBB to use Enano's database abstraction layer.
+ * @package Punano
+ * @subpackage Database compatibility layer
+ * @copyright (C) 2007 Dan Fuhry
+ * @license GNU General Public License
+ */
+
+class PunBB_DBAL_Enano
+{
+
+ var $prefix;
+ var $link_id;
+ var $query_result;
+
+ var $saved_queries = array();
+ var $num_queries = 0;
+
+
+ function PunBB_DBAL_Enano($db_host, $db_username, $db_password, $db_name, $db_prefix, $p_connect)
+ {
+ $this->prefix = table_prefix . 'pun_';
+ }
+
+ function start_transaction()
+ {
+ return;
+ }
+
+ function end_transaction()
+ {
+ return;
+ }
+
+ function query($sql, $unbuffered = false)
+ {
+ global $db;
+ if (defined('PUN_SHOW_QUERIES'))
+ $q_start = get_microtime();
+
+ if ($unbuffered)
+ $this->query_result = $db->sql_unbuffered_query($sql);
+ else
+ $this->query_result = $db->sql_query($sql);
+
+ if ($this->query_result)
+ {
+ if (defined('PUN_SHOW_QUERIES'))
+ $this->saved_queries[] = array($sql, sprintf('%.5f', get_microtime() - $q_start));
+
+ ++$this->num_queries;
+
+ return $this->query_result;
+ }
+ else
+ {
+ if (defined('PUN_SHOW_QUERIES'))
+ $this->saved_queries[] = array($sql, 0);
+
+ return false;
+ }
+ }
+
+ function result($query_id = 0, $row = 0)
+ {
+ return ($query_id) ? @mysql_result($query_id, $row) : false;
+ }
+
+ function fetch_assoc($query_id = 0)
+ {
+ global $db;
+ return ($query_id) ? $db->fetchrow($query_id) : false;
+ }
+
+ function fetch_row($query_id = 0)
+ {
+ global $db;
+ return ($query_id) ? $db->fetchrow_num($query_id) : false;
+ }
+
+
+ function num_rows($query_id = 0)
+ {
+ global $db;
+ return ($query_id) ? @mysql_num_rows($query_id) : false;
+ }
+
+ function affected_rows()
+ {
+ global $db;
+ return ($db->_conn) ? @mysql_affected_rows($db->_conn) : false;
+ }
+
+ function insert_id()
+ {
+ global $db;
+ $ret = ($db->_conn) ? @mysql_insert_id($db->_conn) : false;
+ return $ret;
+ }
+
+ function get_num_queries()
+ {
+ return $this->num_queries;
+ }
+
+ function get_saved_queries()
+ {
+ return $this->saved_queries;
+ }
+
+ function free_result($query_id = false)
+ {
+ global $db;
+ return ($query_id) ? $db->free_result($query_id) : false;
+ }
+
+ function escape($str)
+ {
+ global $db;
+ if (is_array($str))
+ return '';
+ else if (function_exists('mysql_real_escape_string'))
+ return $db->escape($str);
+ else
+ return mysql_escape_string($str);
+ }
+
+
+ function error()
+ {
+ $result['error_sql'] = @current(@end($this->saved_queries));
+ $result['error_no'] = @mysql_errno($this->link_id);
+ $result['error_msg'] = @mysql_error($this->link_id);
+
+ return $result;
+ }
+
+
+ function close()
+ {
+ return false;
+ }
+
+}
+