Skip navigation
Ivejazz55
Currently Being Moderated

Dreamweaver CS5 PHP and MS SQL

May 25, 2010 10:19 AM

Does Dreamweaver CS5 support using PHP with MS SQL?

 
Replies
  • Currently Being Moderated
    May 28, 2010 6:56 AM   in reply to Ivejazz55

    Hi

     

    CS5 does not natively support using php with mssql, but you can use the combination by creating a php:pdo connection to your mssql database.

    For more details on using pdo with mssql see, - http://php.net/manual/en/ref.pdo-dblib.php.

     

    I and many other have been asking the adobe dreamweaver team for pdo to be supported natively in dreamweaver for a few years now in order to enable dw to connect to any database, you may wish to add your 'voice' to this by submitting a feature request at - https://www.adobe.com/cfusion/mmform/index.cfm?name=wishform.

     

    PZ

    www.pziecina.com

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 29, 2010 12:55 PM   in reply to Ivejazz55

    Hi

     

    Do not know if you are still interested in this one, but I now have php with MSSQL working in dreamweaver, (I will be updating my php:pdo extension to include this).

    But if you wish more info on how to use php with mssql let me know.

     

    PZ

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 30, 2010 7:24 AM   in reply to Ivejazz55

    Hi

     

    This works with both the SQL Server 2008 Developers edition and the SQL server 2008 Express edition.

     

    The first thing to ensure is that you have the mssql client for the mssql database installed, (also known as the SQL Server management studio), then go here and download the server driver for php - http://sqlsrvphp.codeplex.com/, I would recommend the release candidate as this support php 5.2 and 5.3, (it is named as "SQL server driver for php 2") yes the name is misleading!

     

    Unpack the file into a temp, directory, then copy the files required to your php extensions directory, (the two files required will depend on your version of php, check the documentation) you do not have to use the pdo file if you are happy creating your own standard sql statements, but doing so will mean that the pdo extension must also be installed for php.

     

    For php 5.2 you would then add the following to your php ini file, (in the extensions section) -

     

    [PHP_MSSQL]
    extension=php_sqlsrv_52_ts_vc6.dll
    [PHP_PDO_MSSQL]
    extension=php_pdo_sqlsrv_52_ts_vc6.dll

     

    If using pdo ensure the following is also included -

     

    [PHP_PDO]
    extension=php_pdo.dll

     

    Restart your server.

     

    O/k, that's the easy part, now to check the installation. For this I installed the "AdventureWorks" database, which you can get here - http://sqlserversamples.codeplex.com/releases/view/45923.

     

    Use the SQL management studio to check the database installed correctly, (while you are there make a note of your server name, and user name and password if not using your windows authentication).

     

    Now to see if the installation is correct/

     

    Open dreamweaver and create a new, (blank) php page, replace all the code, (all the html code) with the following, (the examples give in the help files by Microsoft are wrong) -

    The section I have highlighted in red, change this to match your sql server name.

    <?php
    try {
       $conn = new PDO( "sqlsrv:Server=PAULAS-PC\SQLEXPRESS;Database=AdventureWorks", NULL, NULL);
       $conn->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );}

     

    catch( PDOException $e ) {
       die( "Error connecting to SQL Server" );
    }

     

    echo "Connected to SQL Server\n";

     

    $query = 'select * from Person.ContactType';
    $stmt = $conn->query( $query );
    while ( $row = $stmt->fetch( PDO::FETCH_ASSOC ) ){
       print_r( $row );
    }
    ?>

     

    The NULL and NULL in the connection string, ($conn = new PDO...) indicates that you are using the windows authentication, if not replace these with your user name and password respectively.

     

    Save the page and select 'live view', the first four words should say "Connected to SQL server".

     

    As I said, I am currently working on including the MSsql connection as part of my "php/mysql pdo extension", which is very 'rough code' at the moment and the items are not fully compatible with how dreamweaver normally works, which means I am using mysql for some development, (creating the basic recordsets etc.) and then pasting/modifying the code into the mssql pages for testing.

     

    If your interested, the extension can be downloaded here - http://www.pziecina.com/design/dreamweaver/pdo_extension.php, the log-in/out etc are done but not included yet.

     

    Let me know how you get on with this, and if you have any problems.

     

    Paula Z

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 3, 2010 5:28 AM   in reply to pziecina

    In addition to Paula's extension, you might also be interested to know that you can connect to MS SQL Server using Zend_Db in the Zend Framework.

     

    Instead of creating new server behaviors in CS5, Adobe decided to put a major effort into supporting third-party libraries in Dreamweaver. Code introspection and Site-Specific Code Hints has made working with libraries such as the Zend Framework much easier. I have written "Adobe Dreamweaver CS5 with PHP: Training from the Source", which is due to be published by Adobe Press next month. Only one chapter covers server behaviors. The rest of the book is devoted to working with components of the Zend Framework or a CMS, such as WordPress.

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 10, 2010 1:56 PM   in reply to pziecina

    There are several other ways to connect to MSSQl from PHP. But you gonna have to it by hand. Unless if you use pziecina's PDO extension (by the way, thanks a bunch for that, pziecina).

     

    But take a look at Pear  too. Or something like ezSQL @ http://www.woyano.com/view/213/Download-ezSQL-Database-Class-205

    ezSQL is a database class. Can use it to connect to MSSQL.

     

    Pear is a huge library of PHP mods.. including an excellent database class. And then of course, the big daddy of them all, ZEND.  Though doesn't ZEND use Pear?

     

    And David, I eagerly await your book. I have your other book: PHP object-oriented solutions.

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 22, 2010 7:22 PM   in reply to David_Powers

    Dave: i wrote a very nice review of your dreamweaver cs4 book on amazon. I used your connQuery.php that you suggested in the recordset in your book, but a search on my computer can not find such a file, and the program does not work in gallery_eng.php that we created. The code refers to <?php require_once('/Connections/connQuery');?>  That does not work , but the recordset was created. What can I do about that. I have windows 7 and a wamp server, the latest version. thanks Ken Carlson

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points