Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

php mssql

Posted on 2013-01-04
8
Medium Priority
?
314 Views
Last Modified: 2013-01-07
I have a connection to a ms sql server I would Like to have the same kinder setup that I use with mysql where I call the connection into a recordset and be able to access different columns using

$row_recordset1['column name ']

instead of a array
0
Comment
Question by:beridius
8 Comments
 
LVL 11

Expert Comment

by:Chris Sandrini
ID: 38743111
How do you connect to the mssql server? PDO?
0
 
LVL 39

Expert Comment

by:Pratima Pharande
ID: 38743372
0
 
LVL 84

Expert Comment

by:Dave Baldwin
ID: 38745448
What version of PHP do you have?  What OS/Webserver?  Which version of MS SQL server?  

Details are important here.  PHP 5.2 and below on Windows can use the php_mssql driver while PHP 5.3 and above can not.  PHP 5.3 and above must use sqlsrv driver for direct access.  With the correct SQL Native Client installed, you can also use ODBC to connect.  PDO driver is available in some variations also.

What code are you using right now?
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 9

Expert Comment

by:rinfo
ID: 38746421
use adodb.inc.php
http://adodb.sourceforge.net/
you will have similar function to mssql.
0
 
LVL 111

Accepted Solution

by:
Ray Paseur earned 2000 total points
ID: 38746541
Not to put too fine a point on it, but...
access different columns using $row_recordset1['column name '] instead of a array
The notation you show here is PHP array notation.  You may be surprised how easy it can be to move from your familiar MySQL to MSSQL.  For the most part, I've found that you can replace mysql_query() with mssql_query() and use mssql_fetch_assoc() to retrieve the records from the result resource.  Some notable differences...

There is no analog to mysql_real_escape_string().  I made my own mssql_real_escape_string() function because the idea of using unescaped data made me itch.

The LIMIT clause is different.  In MySQL you might write SELECT thing FROM tbl LIMIT 3 but in MSSQL, you write SELECT TOP(3) thing FROM tbl.

There are other differences, but nothing that was difficult to overcome, and the online documentation you can find with a Google search was always enough to get me going.  But with that said, if I were trying to write a high-performance web service, I would not have tried to do this myself -- I would have hired the MSSQL 3-banana man!

HTH, ~Ray
0
 
LVL 84

Expert Comment

by:Dave Baldwin
ID: 38747158
@beridius does not seem to be responding so we can't know what's going on with him.
0
 
LVL 2

Author Comment

by:beridius
ID: 38750157
sorry thanks for your post the connection to mssql is mssql_query with mssql_fetch_assoc($data))


I dont use PDO. the PHP version is 5.3.14

here is one of my connections
$data = mssql_query("
SELECT      sum(Transactions) + sum(Duplicates)
FROM [SQL01].[dbo].[KPIDay_T]
WHERE        (iDHClientID = 90) AND (UpdtdWhn BETWEEN CONVERT(DATETIME, '$date1', 102) AND CONVERT(DATETIME, '$date2', 102))");
$row = mssql_fetch_assoc($query);

Open in new window

0
 
LVL 2

Author Closing Comment

by:beridius
ID: 38750472
Thanks Ray I checked my Code and you was right I was using a array thanks so much
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses four methods for overlaying images in a container on a web page
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question