Answered Joomla 2.5 and MSSQL Server

  • 19 марта 2012 г. 13:27
     
     

    I have installed Joomla 2.5 on my Windows machine using XAMPP. I have a requirement as follows:

    1. I have to connect to an MSSQL database (MSSQL 2000/2005), residing on  another machine (server), to display information in Joomla 2.5 article, or through a Menu Link.

    2. The information is basically to display the staff list of our company.

    How can I go about It. I am new to Joomla 2.5 and  trying to redesign our website.

    Thanks for your valuable time and reply

    regards

Все ответы

  • 19 марта 2012 г. 15:07
     
     Отвечено С кодом

    If you only need to get data for one article on Joomla, why don't you just use PHP's ODBC driver.  It will avoid the hassle of installing new software.

    Here's an example program:

    header('Content-type: text/plain; charset=UTF-8');
    
    $ODBC_DRIVER = "SQL Server"; // Any SQL Server ODBC driver name can go here.
    
    $connstr = "Driver={{$ODBC_DRIVER}};Server=MY_SERVER_NAME;Database=MY_DATABASE_NAME;";
    
    $conn = odbc_connect($connstr, "uid", "password");
    if ( $conn )
    {
    	$stmt = odbc_exec($conn, "select * from some_table");
    	if ( $stmt )
    	{
    		while ( ($row = odbc_fetch_array($stmt)) )
    		{
    			print_r($row);
    		}
    		odbc_free_result($stmt);
    	}
    	else 
    	{
    		echo 'Exec error: ' . odbc_errormsg();
    	}
    	
    	odbc_close($conn);
    }
    else 
    {
    	echo 'Connection error: ' . odbc_errormsg();
    }
    You require an ODBC driver for SQL Server on the computer running PHP.  If it's Windows, there should already be an ODBC driver called "SQL Server", as in the example.  If there isn't you can download and install the "SQL Server 2008 R2 Native Client" from somewhere on this page: http://www.microsoft.com/download/en/details.aspx?id=16978, then change the driver name in the example to "SQL Server Native Client 10.0".

    Rob

  • 21 марта 2012 г. 17:31
     
     Отвечено

    A simple way to install Joomla is using the Web Gallery:
    http://www.microsoft.com/web/gallery/joomla.aspx

    Cheers,

    Jonathan


    This posting is provided 'AS IS' with no warranties, and confers no rights.