Skip to content

Commit

Permalink
support unicode on MSSQL in quote
Browse files Browse the repository at this point in the history
  • Loading branch information
photodude committed Feb 3, 2017
1 parent 3f130c8 commit f6a5a91
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/Sqlsrv/SqlsrvDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,27 @@ public function escape($text, $extra = false)
return $result;
}

/**
* Quotes and optionally escapes a string to database requirements for use in database queries.
*
* @param mixed $text A string or an array of strings to quote.
* @param boolean $escape True (default) to escape the string, false to leave it unchanged.
*
* @return string The quoted input string.
*
* @since __DEPLOY_VERSION__
*/
public function quote($text, $escape = true)
{
if (is_array($text))
{
return parent::quote($text, $escape);
}

// To support unicode on MSSQL we have to add prefix N
return 'N\'' . ($escape ? $this->escape($text) : $text) . '\'';
}

/**
* Determines if the connection to the server is active.
*
Expand Down

0 comments on commit f6a5a91

Please sign in to comment.