Discussion:
Querying MicroSoft SQL server from within WordPress
Haluk Karamete
2014-05-03 21:05:58 UTC
Permalink
What's the most recommended way to query MS-SQL from WordPress?

I'd like to use the WordPress Database API's and the available functions as
much as I can. Does the current codebase ( 3.9with the myqli ) support
this?

Or do I need to write my own code using PDO?
In my theme, I need to query MSSQL and display the results within a page.
That's what I'm up against.
Nicholas Ciske
2014-05-03 21:22:20 UTC
Permalink
Post by Haluk Karamete
What's the most recommended way to query MS-SQL from WordPress?
Not sure this really exists... see below for why.
Post by Haluk Karamete
I'd like to use the WordPress Database API's and the available functions as
much as I can. Does the current codebase ( 3.9with the myqli ) support
this?
WordPress does not natively support databases other than MySQL. YMMV, but I'm not sure you can repoint WP_Query to MSSQL without hacking core, or that it would even work if you did.

No, mysqli does not support MS SQL -- it's a MySQL library (hence the name ;-).
http://www.php.net/manual/en/intro.mysqli.php

See also:
https://codex.wordpress.org/Using_Alternative_Databases
Post by Haluk Karamete
Or do I need to write my own code using PDO?
PDO
or
http://www.php.net/manual/en/intro.mssql.php
or
http://msdn.microsoft.com/en-us/sqlserver/ff657782.aspx

Depends on what version of MS SQL you’re connecting to, and which version of PHP you’re going to run the code in (as well as what the host has enabled).

_________________________
Nick Ciske
http://thoughtrefinery.com/
@nciske
Post by Haluk Karamete
What's the most recommended way to query MS-SQL from WordPress?
I'd like to use the WordPress Database API's and the available functions as
much as I can. Does the current codebase ( 3.9with the myqli ) support
this?
Or do I need to write my own code using PDO?
In my theme, I need to query MSSQL and display the results within a page.
That's what I'm up against.
_______________________________________________
wp-hackers mailing list
http://lists.automattic.com/mailman/listinfo/wp-hackers
Ryan McCue
2014-05-04 02:06:49 UTC
Permalink
Post by Haluk Karamete
Or do I need to write my own code using PDO?
In my theme, I need to query MSSQL and display the results within a page.
That's what I'm up against.
You'll have to write your own code for this. wpdb is heavily reliant on
MySQL, and isn't really intended for use outside of WP core.

If you want a similar class for MSSQL, you could try something like
Doctrine's DBAL: http://www.doctrine-project.org/

Thanks,
Ryan

Loading...