tonict / phalcon-sqlsrv Goto Github PK
View Code? Open in Web Editor NEWPhalcon - MS SQL Server (PDO) Adapter
Phalcon - MS SQL Server (PDO) 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 ;)
Manual?
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!!
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.
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?
how to use this in ubuntu server sqlsrv not working in linux thank you i have problem using this in ubuntu server but in windows working fine
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.