[Astrospaces-commits] SF.net SVN: astrospaces: [3] trunk
Brought to you by:
p3net
From: <p3...@us...> - 2007-03-11 02:18:37
|
Revision: 3 http://astrospaces.svn.sourceforge.net/astrospaces/?rev=3&view=rev Author: p3net Date: 2007-03-10 18:18:38 -0800 (Sat, 10 Mar 2007) Log Message: ----------- -Finish basic database abstraction -Add uploads directory (for avatars and stuff) -Fix the misformed header portion (the copyright) on includes/db.php -Fix the misformed header portion (the copyright) on common.php Modified Paths: -------------- trunk/common.php trunk/includes/db.php Added Paths: ----------- trunk/uploads/ Modified: trunk/common.php =================================================================== --- trunk/common.php 2007-03-10 23:36:04 UTC (rev 2) +++ trunk/common.php 2007-03-11 02:18:38 UTC (rev 3) @@ -1,7 +1,7 @@ <?php /****************************************************************************** -* common.php * -* AstroSPACES 2 * +* common.php * +* AstroSPACES 2 * * * * Description: common.php is included by every script in the AstroSPACES * * package. It sets up things we need for every page, like sessions, * Modified: trunk/includes/db.php =================================================================== --- trunk/includes/db.php 2007-03-10 23:36:04 UTC (rev 2) +++ trunk/includes/db.php 2007-03-11 02:18:38 UTC (rev 3) @@ -1,7 +1,7 @@ <?php /****************************************************************************** -* includes/db.php * -* AstroSPACES 2 * +* includes/db.php * +* AstroSPACES 2 * * * * Description: db.php handles database abstraction, making AstroSPACES * * compatible with multiple db engines. It also handles connecting to the db, * @@ -21,8 +21,8 @@ * with this program; if not, write to the Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * * * -* ID: $Id$ * -* Author: $Author$ * +* ID: $Id:$ * +* Author: $Author:$ * ******************************************************************************/ //Die if this file was accessed directly @@ -55,7 +55,7 @@ } //Connect to a Postgre SQL database - else if($dmbs = "pgsql") + else if($dmbs == "pgsql") { pg_connect("host=" . $db_server . " dbname=" . $db_database . " dbuser=" . $db_user . " db_password=" . $db_password) or general_error("Could not connect to database"); @@ -72,5 +72,35 @@ define('DB_CONFIG', $prefix . "config"); define('DB_THEMES', $prefix . "themes"); } + function query($query) + { + //Query for SQL databases + + //MySQL + if($dbms == "mysql") + { + $_query=mysql_query($query) or general_error("Error executing query " . $query . ": " . mysql_error()); + return $_query; + } + + //PostgreSQL + else if($dmbs == "pgsql") + { + $_query=pg_query($query) or die("Error executing query " . $query . ": " . pg_error()); + } + } + function array($_query) + { + //We're going to assume $_query is a resource. If it isn't, something's wrong. + if($dbms == "mysql") + { + $result=mysql_fetch_array($_query) or general_error("Could not fetch array: " . mysql_error()); + return $result; + } + else if($dbms == "pgsql") + { + $result=pg_fetch_array($_query) or general_error("Could not fetch array: " . pg_error()); + } + } } ?> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |