Git Product home page Git Product logo

sqlshim's Introduction

sqlshim • sqlsrv for Linux/OS X

sqlshim replicates sqlsrv (Microsoft SQL Server Driver for PHP) functionality on Linux/OS X.

It began as a small set of spoofed sqlsrv functions and has since evolved into a full-on sqlsrv replacement.

It is currently in alpha and is primarily intended for use in dev environments or non-mission-critical applications. But I can't tell you what to do.

Getting Started

  1. $ composer require "radsectors/sqlshim:dev-master"
  2. <?php require 'vendor/autoload.php';
  3. ???
  4. Profit!

See the wiki for more detailed documentation and support.

Contributing

See CONTRIBUTING.md for contribution info.

❤ sqlshim? Send 💸!

License

See LICENSE for license info.

sqlshim's People

Contributors

dinglidingli avatar owenelisa avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

sqlshim's Issues

Interpretation of Strings to DateTime

if i have a column in SQL with a value like xxx-yy-zz. I received the folowing error:
[Tue Apr 04 15:02:05.023778 2017] [:error] [pid 8562] [client xxxx:57350] PHP Fatal error: Uncaught Exception: DateTime::__construct(): Failed to parse time string (2126-82-04) at position 6 (2): Unexpected character in /var/www/xxx/sqlshim.php:297\nStack trace:\n#0 /var/www/xxx/sqlshim.php(297): DateTime->__construct('2126-82-04')\n#1 /var/www/xxx/sqlshim.php(269): radsectors\sqlshim::typifyField('2126-82-04')\n#2 /var/www/xxx/sqlshim.php(617): radsectors\sqlshim::typifyRow(Array)\n#3 /var/www/xxx/globals.php(275): radsectors\sqlshim::fetch_array(Object(PDOStatement), 3, 1, 0)\n#4 /var/www/xxx/test.php(46): sqlsrv_fetch_array(Object(PDOStatement))\n#5 {main}\n thrown in /var/www/xxx/sqlshim.php on line 297, referer: https://xxxxxxx/

If i uncomment the lines of the function i can't use real DateTime Columns where the value is like YYYY-MM-DD HH:ii:ss

I need to use both options and need help.

PHPTYPE_STR(EAM|ING) Inconsistency

Something very strange is happening with the PHPTYPE_STR(EAM|ING) functions from the official sqlsrv drivers. Randomly, they return different values. I've decided they are the "incorrect" values based on how often they are returned, which is far less often than the ones I've deemed as "correct." If the inconsistency is intended, then I'd like to understand it in order to replicate it. I've snooped around the code over on Azure/msphpsql but could not find anything helpful.

Unit Tests Wanted

Are you good at writing unit tests?

Write some tests for sqlshim and submit your pull request.

Currently we're using phpunit, but I'm 100% open to alternatives.

Install on Mac El Capitan with PHP 7

I am having trouble getting sqlshim to work on my Mac. I am using PHP 7. I have also installed FreeTDS and confirmed it works. How do I setup sqlshim and FreeTDS to work together on Mac?

Issue connecting to Azure Database

Hi there,

I found this library today and i'm trying to use it in my Linux webserver... But i can't manage to connect to my server.

i'm using this code:

"user@server", "pwd" => "myPassword", "Database" => "MyDB", "LoginTimeout" => 30, "Encrypt" => 1, "TrustServerCertificate" => 0); $serverName = "tcp:myserver.database.windows.net,1433"; $conn = sqlsrv_connect($serverName, $connectionInfo); ``` if( $conn ) { echo "Connection established.
"; ``` }else{ echo "Connection could not be established.
"; die( print_r( sqlsrv_errors(), true)); } ?>

Can you give me a connection example?

Thank you very much

Doctrine - SQL Server error occurred but no error message was retrieved from driver.

I'm trying to connect to our Sql Server from my Mac using sqlshim.

Doctrine gives me the following exception which is not helpful at all:

object(Doctrine\DBAL\Driver\SQLSrv\SQLSrvException)#279 (7) {
  ["message":protected]=>
  string(73) "SQL Server error occurred but no error message was retrieved from driver."
  ...

The specified driver for Doctrine is sqlsrv. I've tested the credentials using the SQLPro for MSSQL application and they are indeed correct. What can I do?

Thanks for your help!

Problems querying fields of SQLTYPE_TEXT

Quoting comment left on issue #3 by @dexterfichuk:

...problems querying tables that have a field with the datatype text. As soon as it reaches that field, it returns none of the following fields back. If I cast it in my query to a varchar though it fixes everything.
Ref: #3 (comment)

My questions:

  • Clarify: you're getting no error, you're simply not getting all of the fields back?
  • Have you tested the problem queries in a windows/sqlsrv environment? Or even in SSMS or Toad or something?
  • If no, do you have a way to do so?

Just wanna rule out sql server before I start looking at sqlshim.

thanks!

Character Entities on Mac

On Mac, when you json_encode an array containing Spanish characters/entities, the operation fails silently and no output is given. Running json_encode on an array with no special chars works fine.

Shown below is the print_r output for an array containing ó.

Array
(
    [0] => Array
        (
            [workid] => 8744
            [trending] => 1
            [work_slug] => 
            [title] => Edici�n compacta NTV letra grande, DuoTono
            [title_sort] => Edici�n compacta NTV letra grande, DuoTono

Blank Array ( )

I'm trying to connect using sqlhim to a data base on OSX,
I all ready install sqlhim via composer on my path for my connection but it give me the follow error just print array() on the sqlsrv_error()

require 'vendor/autoload.php';
$serverName = "10.10.1.10";
$connectionInfo = array("Database"=>"datosdb", "UID"=>"sa", "PWD"=>"PASSWORD");
echo "Here i just print the $connectionInfo var_dump ->";
var_dump($connectionInfo);
echo "
";
$conn = sqlsrv_connect($serverName, $connectionInfo);
if($conn){
echo "Connected";
}else {
echo "Conection faild
";
die(print_r(sqlsrv_errors(), true));
}

value type binding

Hello,

I was wondering how we can go about binding parameters / values as inputs / outputs with this shim. This also encompasses manual definition of the value's SQL type.

Passing the params to sqlsrv_query (documented on http://php.net/manual/en/function.sqlsrv-query.php) in a format like:

[
  ['value1', SQLSRV_PARAM_IN],
  ['value2', SQLSRV_PARAM_INOUT],
  ['value3', SQLSRV_PARAM_OUT],
]

results in an array to string conversion error (likely due to the shim expecting parameters to not be arrays)

SQLTYPE_(DECIMAL|NUMERIC) Logic Clean-up

The logic in the SQLTYPE_(DECIMAL|NUMERIC) functions seems pretty messy to me. If any math whizzes can see any pattern(s) I've missed, or if any C++ gurus or sqlsrv experts out there can shed some light on how these numbers are calculated, please, PLEASE do. I've snooped around the code over on Azure/msphpsql but was only able to find just a small amount of useful information.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.