Welcome Guest, Not a member yet? Register   Sign In
MsSQL Adapter / ActiveRecord
#1

[eluser]Pygon[/eluser]
Not exactly sure what's going on here but this is driving me crazy.

ActiveRecord seems to be escaping all column names with double-quotes, however this is causing all queries to fail.

Taking the same query and placing it in MsSQL Administrator gives the correct results.

Anyone else run into this and possibly have a solution? Really doesn't seem to make any sense, unless MsSQL Administrator is stripping these double-quotes around column names or something wonky is happening to these double-quotes.

Example:
Code:
$this->db->select('column1,column2')->from('table');
$this->db-get(); //fails

$this->db->select('column1,column2',FALSE)->from('table');
$this->db->get(); //works

This by itself isn't the biggest issue -- the biggest issue is that I cannot join() anything.

I haven't gotten much further in, but I have a good feeling the MSSQL adapter is going to blow chunks on plenty of other things.
#2

[eluser]Pygon[/eluser]
Looks like this solves the problem:

[quote author="Late Night Again" date="1202982512"]I do not know if this is the correct fix but it has resolved my problem, here is what I have dont.

mssql_driver.php - line 461

Changed
Code:
$item = preg_replace('/(^'.$lbound.')([\w\d\-\_]+?)(\s|\)|$)/iS', '$1"$2"$3', $item);

To
Code:
$item = preg_replace('/(^'.$lbound.')([\w\d\-\_]+?)(\s|\)|$)/iS', '$1$2$3', $item);

AND

line 465

Changed
Code:
return "\"{$item}\"";

To
Code:
return "{$item}";

This may not be a correct fix but hopefully will help you out till there is a bug fix.[/quote]
#3

[eluser]Stuart Marsh[/eluser]
Cheers for this!
I had the same problem and the above changes sorted it.
I have created a bug report so hopefully it'll be sorted in a future release.
#4

[eluser]bscott[/eluser]
Would it be better to replace the quotes with [..] rather than remove them?

ie:-

$item = preg_replace('/(^'.$lbound.')([\w\d\-\_]+?)(\s|\)|$)/iS', '$1[$2]$3', $item);




Theme © iAndrew 2016 - Forum software by © MyBB