Code Monkey home page Code Monkey logo

phalcon-sqlsrv's People

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

phalcon-sqlsrv's Issues

Warn in Adapter

Hi,

I'm trying your library in linux, but I recive a warn in the Adapter Class.

In Adapter/Pdo/Sqlsrv.php
PDO::__construct() expects at most 4 parameters, 5 given in Adapter/Pdo/Sqlsrv.php line 345

Then I recive a message saying
Table 'xxx' doesn't exist in database when dumping meta-data for Xxx

I'm tried to launf statement directly in linw 345 changing the code by;
return parent::query($sqlStatement, $bindParams, $bindTypes);

but still dont work, I recive the message:
Trying to call method fetch on a non-object
#0 [internal function]: Phalcon\Db\Result\Pdo->numRows(Object(Phalcon\Db\Result\Pdo))

Thanks for your work ;)

Problem with the numRows of aResultset

Hello,

I'm using your adapter class sucessfully but I have a bug when reading de recordount of the Resulset

Making a simple test (provided by phalcon documentation)

$robots = Robots::find();
print_r($robots->count());

Return -1 but the resultset have 3 records

I think the problem is that you override the numRows function in your PdoSqlsrv Result Class and ommit the "select count(*)..." that phalcon do, but I'm not sure.

Here is a var_dump of the robots object:

object(Phalcon\Mvc\Model\Resultset\Simple)[52]
  protected '_result' => 
    object(Phalcon\Db\Result\PdoMssql)[54]
      protected '_connection' => 
        object(plugins\MSSQL\Adapter\Mssql)[48]
          protected '_type' => string 'sqlsrv' (length=6)
          protected '_dialectType' => string 'sqlsrv' (length=6)
          protected '_eventsManager' => null
          protected '_descriptor' => 
            array (size=6)
              ...
          protected '_dialect' => 
            object(plugins\MSSQL\Dialect\Mssql)[51]
              ...
          protected '_connectionId' => int 0
          protected '_sqlStatement' => null
          protected '_sqlVariables' => null
          protected '_sqlBindTypes' => null
          protected '_transactionLevel' => int 0
          protected '_transactionsWithSavepoints' => boolean false
          protected '_pdo' => 
            object(PDO)[49]
              ...
          protected '_affectedRows' => null
      protected '_result' => null
      protected '_fetchMode' => int 2
      protected '_pdoStatement' => 
        object(PDOStatement)[55]
          public 'queryString' => string 'SELECT "robots"."id", "robots"."name", "robots"."type", "robots"."year" FROM "robots"' (length=85)
      protected '_sqlStatement' => string 'SELECT "robots"."id", "robots"."name", "robots"."type", "robots"."year" FROM "robots"' (length=85)
      protected '_bindParams' => null
      protected '_bindTypes' => null
      protected '_rowCount' => int -1
  protected '_cache' => null
  protected '_isFresh' => boolean true
  protected '_pointer' => int 0
  protected '_count' => int -1
  protected '_activeRow' => null
  protected '_rows' => 
    array (size=3)
      0 => 
        array (size=4)
          'id' => string '8' (length=1)
          'name' => string 'Robotina' (length=8)
          'type' => string 'mechanical' (length=10)
          'year' => string '1972' (length=4)
      1 => 
        array (size=4)
          'id' => string '9' (length=1)
          'name' => string 'Astro Boy' (length=9)
          'type' => string 'mechanical' (length=10)
          'year' => string '1952' (length=4)
      2 => 
        array (size=4)
          'id' => string '10' (length=2)
          'name' => string 'Terminator' (length=10)
          'type' => string 'cyborg' (length=6)
          'year' => string '2029' (length=4)
  protected '_row' => null
  protected '_errorMessages' => null
  protected '_hydrateMode' => int 0
  protected '_model' => 
    object(Robots)[47]
      public 'id' => null
      public 'name' => null
      public 'year' => null
      public 'type' => null
      protected '_dependencyInjector' => 
        object(Phalcon\Di\FactoryDefault)[5]
          protected '_services' => 
            array (size=23)
              ...
          protected '_sharedInstances' => 
            array (size=7)
              ...
          protected '_freshInstance' => boolean false
          protected '_eventsManager' => null
      protected '_modelsManager' => 
        object(Phalcon\Mvc\Model\Manager)[43]
          protected '_dependencyInjector' => 
            object(Phalcon\Di\FactoryDefault)[5]
              ...
          protected '_eventsManager' => null
          protected '_customEventsManager' => null
          protected '_readConnectionServices' => null
          protected '_writeConnectionServices' => null
          protected '_aliases' => null
          protected '_hasMany' => null
          protected '_hasManySingle' => null
          protected '_hasOne' => null
          protected '_hasOneSingle' => null
          protected '_belongsTo' => null
          protected '_belongsToSingle' => null
          protected '_hasManyToMany' => null
          protected '_hasManyToManySingle' => null
          protected '_initialized' => 
            array (size=1)
              ...
          protected '_sources' => 
            array (size=1)
              ...
          protected '_schemas' => null
          protected '_behaviors' => null
          protected '_lastInitialized' => 
            &object(Robots)[47]
          protected '_lastQuery' => null
          protected '_reusable' => null
          protected '_keepSnapshots' => null
          protected '_dynamicUpdate' => null
          protected '_namespaceAliases' => null
      protected '_modelsMetaData' => null
      protected '_errorMessages' => null
      protected '_operationMade' => int 0
      protected '_dirtyState' => int 1
      protected '_transaction' => null
      protected '_uniqueKey' => null
      protected '_uniqueParams' => null
      protected '_uniqueTypes' => null
      protected '_skipped' => null
      protected '_related' => null
      protected '_snapshot' => null
  protected '_columnMap' => null
  protected '_keepSnapshots' => boolean false

Thanks!!

not work in Phlacon 3.0 and PHP 7

I know that this lib is not support phalcon 3 and php7, but few small changes make it run.
I had to install php7.0-sybase and php-sybase

All changes are in Phalcon/Db/Adapter/Pdo/Sqlsrv.php

first: change declaration of connect function:

from: public function connect($descriptor = null)
to: public function connect(array $descriptor = null)

second: change connection via PDO
from:
$this->_pdo = new \PDO("sqlsrv:server={$descriptor['host']}:1433;database={$descriptor['dbname']}", $descriptor['username'], $descriptor['password'], $options);
to:
`$options[\PDO::ATTR_ERRMODE] = \PDO::ERRMODE_EXCEPTION;
$options[\PDO::ATTR_STRINGIFY_FETCHES] = true;

    $dsn= "dblib:host=".$descriptor['host'].":1433;dbname=".$descriptor['dbname'].";";
    $dbusername=$descriptor['username'];
    $dbpassword=$descriptor['password'];

    $this->_pdo = new \PDO($dsn,$dbusername,$dbpassword);
    $this->_pdo->setAttribute(\PDO::ATTR_ERRMODE,\PDO::ERRMODE_EXCEPTION);`

third and last: change declaration $dialectClass variable from:

$dialectClass = 'Phalcon\\Db\\Dialect\\' . $this->_dialectType;
to: $dialectClass = 'Phalcon\\Db\\Dialect\\' . ucfirst($this->_dialectType);

that changes help me and let use this lib co connect with mssql.

Allowed memory exhausted in pagination

Hey,
I try this rep for testing, in Phalcon 3 IIS 10 MSSQL 2016
for pagination, I got this error:

Fatal error: Allowed memory size of 2147483648 bytes exhausted (tried to allocate 8029744912849722552 bytes) in C:\Inetpub\vhosts\hotbookmakers.com\httpdocs\api\app\library\Phalcon\Db\Dialect\Sqlsrv.php on line 50

:APL0" {"code":"HY090","status":"error","message":"SQLSTATE[HY090]: [Microsoft][ODBC Driver Manager] Invalid string or buffer length"}SQLSTATE[HY090]: [Microsoft][ODBC Driver Manager] Invalid string or buffer length

any idea?

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.