Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #17 from ioscream/patch-1

Update sqlsrv/ez_sql_sqlsrv.php
  • Loading branch information...
commit 589ed00f0156cac09c8b784d79792972a130d603 2 parents 6877c84 + c8220c0
@jv2222 jv2222 authored
Showing with 35 additions and 31 deletions.
  1. +35 −31 sqlsrv/ez_sql_sqlsrv.php
View
66 sqlsrv/ez_sql_sqlsrv.php
@@ -242,7 +242,8 @@ function query($query)
$name = strtolower($name);
if ($name == "size") $name = "max_length";
else if ($name == "type") $name = "typeid";
-
+ //DEFINED FOR E_STRICT
+ $col = new StdClass();
$col->{$name} = $value;
}
@@ -315,11 +316,11 @@ function ConvertMySqlToMSSql($query)
1 => "\\1",
2 => "");
preg_match($limit_str, $query, $regs);
- $query = preg_replace($patterns, $replacement, $query);
-
- if($regs[2])
+ $query = preg_replace($patterns, $replacements, $query);
+
+ if(isset($regs[2]))
$query = str_ireplace("SELECT ", "SELECT TOP ".$regs[3]." ", $query);
- else if($regs[1])
+ else if(isset($regs[1]))
$query = str_ireplace("SELECT ", "SELECT TOP ".$regs[1]." ", $query);
return $query;
@@ -330,32 +331,35 @@ function get_datatype($col)
{
global $ezsql_sqlsrv_type2str_non_dup;
$datatype = "dt not defined";
- switch ($col->typeid) {
- case -2 :
- if ($col->max_length < 8000)
- $datatype = "binary";
- else
- $datatype = "timestamp";
- break;
- case 3 :
- if (($col->scale == 4) && ($col->precision == 19))
- $datatype = "money";
- else if (($col->scale == 4) && ($col->precision == 10))
- $datatype = "smallmoney";
- else
- $datatype = "decimal";
- break;
- case 93 :
- if (($col->precision == 16) && ($col->scale == 0))
- $datatype = "smalldatetime";
- else if (($col->precision == 23) && ($col->scale == 3))
- $datatype = "datetime";
- else
- $datatype = "datetime2";
- break;
- default :
- $datatype = $ezsql_sqlsrv_type2str_non_dup[$col->typeid];
- break;
+ if(isset($col->typeid))
+ {
+ switch ($col->typeid) {
+ case -2 :
+ if ($col->max_length < 8000)
+ $datatype = "binary";
+ else
+ $datatype = "timestamp";
+ break;
+ case 3 :
+ if (($col->scale == 4) && ($col->precision == 19))
+ $datatype = "money";
+ else if (($col->scale == 4) && ($col->precision == 10))
+ $datatype = "smallmoney";
+ else
+ $datatype = "decimal";
+ break;
+ case 93 :
+ if (($col->precision == 16) && ($col->scale == 0))
+ $datatype = "smalldatetime";
+ else if (($col->precision == 23) && ($col->scale == 3))
+ $datatype = "datetime";
+ else
+ $datatype = "datetime2";
+ break;
+ default :
+ $datatype = $ezsql_sqlsrv_type2str_non_dup[$col->typeid];
+ break;
+ }
}
return $datatype;
Please sign in to comment.
Something went wrong with that request. Please try again.