Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions models/datasources/dbo/dbo_sqlsrv.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class DboSqlsrv extends DboSource {
*/
var $columns = array(
'primary_key' => array('name' => 'IDENTITY (1, 1) NOT NULL'),
'string' => array('name' => 'varchar', 'limit' => '255'),
'string' => array('name' => 'nvarchar', 'limit' => '6000'), // ICC this limit doesn't seem to matter, I set it to 6000 anyway which is equivalent to nvarchar(3000)
'text' => array('name' => 'text'),
'integer' => array('name' => 'int', 'formatter' => 'intval'),
'float' => array('name' => 'numeric', 'formatter' => 'floatval'),
Expand Down Expand Up @@ -296,6 +296,9 @@ function value($data, $column = null, $safe = false) {

if (in_array($column, array('integer', 'float', 'binary')) && is_numeric($data)) {
return $data;
} else if ($column == 'string') {
// ICC we are assuming all string data is unicode now
return "N'" . $data . "'";
}
return "'" . $data . "'";
}
Expand Down Expand Up @@ -680,15 +683,20 @@ function fetchResult() {
if ($row = sqlsrv_fetch_array($this->results, SQLSRV_FETCH_NUMERIC)) {
$resultRow = array();
$i = 0;

foreach ($row as $index => $field) {
$a = $this->map[$index];
list($table, $column) = $a;
list($table, $column) = $this->map[$index];
if (is_a($row[$index], 'DateTime')) {
$dateTimeObj = $row[$index];
$row[$index] = $dateTimeObj->format('Y-m-d H:i:s');
}
$resultRow[$table][$column] = $row[$index];
$i++;
}
return $resultRow;
} else {
return false;
}
return false;
}

/**
Expand Down
2 changes: 2 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
This plugin contains various datasources contributed by the core CakePHP team and the community.
The datasources plugin is compatible with CakePHP 1.3+.

ICC - for this plugin I have modifed the sqlsrv driver to allow UTF-8 characters and make it more compatible with CakePHP v1.2.

### Using the datasources plugin

First download the repository and place it in `app/plugins/datasources` or on one of your plugin paths. You can then import and use the datasources in your App classes.
Expand Down