coppermine-gallery.com/forum

Support => cpg1.3.x Support => Older/other versions => cpg1.3 Installation & Setup => Topic started by: RevoD on August 17, 2004, 04:31:10 AM

Title: can this work with MSSQL
Post by: RevoD on August 17, 2004, 04:31:10 AM
my clients server runs MSSQL, can I still use this script with this type of database management on a windows server?
Title: Re: can this work with MSSQL
Post by: Joachim Müller on August 17, 2004, 07:21:55 AM
without modification of coppermine core code: no. There have been plans on database abstraction, but so far they only exist in some developer's minds. Coppermine works currently only with mySQL.

GauGau
Title: Re: can this work with MSSQL
Post by: radianation on August 20, 2004, 06:59:07 AM
What exactly needs to be changed in order for it to work with MSSQL? An idea of the scope would be enough. Thanks.
Title: Re: can this work with MSSQL
Post by: Joachim Müller on August 20, 2004, 07:40:16 AM
no idea, I have never worked with mssql. Inside the main function declaration of coppermine there's the connection function (there is a slight degree of db abstarction in coppermine). You might want to take a look at include/functions.inc.php, find/**************************************************************************
   Database functions
**************************************************************************/

// Connect to the database
function cpg_db_connect()
{
        global $CONFIG;
        $result = @mysql_connect($CONFIG['dbserver'], $CONFIG['dbuser'], $CONFIG['dbpass']);
        if (!$result)
                return false;
        if (!mysql_select_db($CONFIG['dbname']))
                return false;
        return $result;
}

// Perform a database query
function db_query($query, $link_id = 0)
{
        global $CONFIG, $query_stats, $queries;

        $query_start = cpgGetMicroTime();
        if (($link_id)) {
            $result = mysql_query($query, $link_id);
        } else {
                $result = mysql_query($query);
        }
        $query_end = cpgGetMicroTime();
        if (isset($CONFIG['debug_mode']) && (($CONFIG['debug_mode']==1) || ($CONFIG['debug_mode']==2) )) {
                $query_stats[] = $query_end - $query_start;
                $queries[] = $query;
        }
        if (!$result) db_error("While executing query \"$query\" on $link_id");

        return $result;
}

// Error message if a query failed
function db_error($the_error)
{
        global $CONFIG;

        if (!$CONFIG['debug_mode']) {
            cpg_die(CRITICAL_ERROR, 'There was an error while processing a database query', __FILE__, __LINE__);
        } else {

                $the_error .= "\n\nmySQL error: ".mysql_error()."\n";

                $out = "<br />There was an error while processing a database query.<br /><br/>
                    <form name='mysql'><textarea rows=\"8\" cols=\"60\">".htmlspecialchars($the_error)."</textarea></form>";

            cpg_die(CRITICAL_ERROR, $out, __FILE__, __LINE__);
        }
}

// Fetch all rows in an array
function db_fetch_rowset($result)
{
        $rowset = array();

        while ($row = mysql_fetch_array($result)) $rowset[] = $row;

        return $rowset;
}
Maybe it already works if you change those lines to work with mssql, but if it doesn't I'm afraid you will have to look into nearly every file, as they do the actual queries.

GauGau
Title: Re: can this work with MSSQL
Post by: Goatie on February 17, 2006, 11:54:48 AM
Just wondered if any advance had been made in cpg1.4 in regard to database type abstraction or indeed whether or not MSSQL is now supported?
Title: Re: can this work with MSSQL
Post by: Nibbler on February 17, 2006, 12:11:49 PM
Please don't ask about 1.4 on the 1.3 support board. There is no support for mssql in 1.4
Title: Re: can this work with MSSQL
Post by: Goatie on February 17, 2006, 03:36:47 PM
My Apologies. Just didn't see the point in starting a new thread based on an existing topic.