Ticket #448 (closed Feature Request: fixed)

Opened 9 months ago

Last modified 7 months ago

MSSQL Driver

Reported by: ixmatus Owned by: zombor
Priority: major Milestone: 2.2
Component: Libraries:Database Version: SVN HEAD
Keywords: database, mssql, drivers Cc:

Description

This is an alpha version of the MSSQL driver ported over from the MySQL driver. Thus far my tests on the features that are present have all been successful. I have not done any thorough unit testing of all the driver's functionality yet.

I had to custom write a character escaping function using addcslashes() as there was no equivalent to the mysql_real_escape_string() function.

The table and column escaping conventions are different - instead of to escape, [] are used.

Line 58 in the MySQL Driver:

$port = isset($port) ? ':'.$port : '';

has been changed in the MSSQL Driver to:

$port = (isset($port) AND is_string($port)) ? ':'.$port : '';

because errors were being produced due to the : being appended to the server name.

There are a number of features that had to be commented out of the driver that were standard in the MySQL driver. is_string() is used because the port designation is given in the DSN as a string of integers; although it could be made more robust to ensure it is an actual number. Would need to type cast it into an int then test it - maybe for another version.

These missing features include:

* REGEX

  • no parallel equivalent

* NOT REGEX

  • no parallel equivalent

* LIMIT

  • equivalent in T-SQL is TOP, but in SQL Server 2000 there is no equivalent to OFFSET
  • the offset parameter for the mssql::limit() method is now set to null so it conforms with the database interface class

* MERGE

  • no parallel equivalent to MERGE or UPSERT

* SET NAMES

  • no parallel equivalent

Attachments

Mssql.php.tar.gz (4.5 kB) - added by ixmatus 9 months ago.
MSSQL Driver
Mssql.php.tar.2.gz (4.5 kB) - added by ixmatus 9 months ago.
MSSQL Driver 0.2
Mssql.php.tar.3.gz (4.5 kB) - added by ixmatus 9 months ago.
MSSQL Driver 0.3
Mssql.php.tar.4.gz (4.4 kB) - added by ixmatus 9 months ago.
MSSQL Driver 0.4

Change History

Changed 9 months ago by ixmatus

MSSQL Driver

Changed 9 months ago by ixmatus

Note:

"The table and column escaping conventions are different - instead of to escape, [] are used."

The back ticks don't show up, it should read like this:

"The table and column escaping conventions are different - instead of

``

to escape, [] are used."

Changed 9 months ago by ixmatus

Okay, I already have some bug fixes.

Major one: the mssql_fetch_object doesn't have the same params mysql_fetch_object has... I had to remove the $this->return_type.

Changed 9 months ago by ixmatus

MSSQL Driver 0.2

Changed 9 months ago by ixmatus

There seems to be a bug in my character escaping function - I am switching to preg_replace until I can figure out what I did wrong.

Changed 9 months ago by ixmatus

MSSQL Driver 0.3

Changed 9 months ago by ixmatus

Appears there is nothing wrong with the escaping function, but with how data is being written, I am noticing it while the session library interacts with it...

Changed 9 months ago by ixmatus

MSSQL Driver 0.4

Changed 9 months ago by zombor

  • status changed from new to closed
  • resolution set to fixed

Since this is in SVN now, I am closing this ticket. If there are more changes, please create a new ticket (bug or feature request) with a patch attached.

Changed 7 months ago by aston

This isn't a bug really, but rather just an FYI to anyone using this driver. I'm currently running version 2.1.1 of Kohana, so later versions may have already addressed this issue.

One thing you got to do if you're planning on using the escape_str() method (which is used if you're doing query binding), you needed to be sure to add an 'escape' key to your $config array inside /application/config/database.php.

Aside from that, I've had very little issues with it.

Great work, ixmatus!

Note: See TracTickets for help on using tickets.