[wp-hackers] Querying MicroSoft SQL server from within WordPress

Nicholas Ciske nl at thoughtrefinery.com
Sat May 3 21:22:20 UTC 2014


> What's the most recommended way to query MS-SQL from WordPress?

Not sure this really exists... see below for why.

> 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


> 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	

On May 3, 2014, at 4:05 PM, Haluk Karamete <halukkaramete at gmail.com> wrote:

> 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
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers



More information about the wp-hackers mailing list