Driver does not support this function

Notice: This thread is very old.
richard
Member | 60
+
0
-

I have a piece of code which works fine with PDO but does not work with the Nette:

<?php

$sql = "select * from db..table";

// this works OK
$dbh = new PDO('mssql:host=xxx;dbname=db','xxx','xxx');
$stmt = $dbh->prepare($sql);
$stmt->execute();
while ($row = $stmt->fetch()) {
	print_r($row);
}

// this does not work
$stmt = $this->database->prepare($sql);
$stmtt->execute();
while ($row = $stmt->fetch()) {
	print_r($row);
}
?>

config.neon

nette:
database:
dsn: ‘mssql:host=xxx;dbname=db’
user: xxx
password: xxx

Error: SQLSTATE[IM001]: Driver does not support this function: driver doesn't support meta data

With fetchAll() I get:
SQLSTATE[HY000]: General error: could not call class constructor

I have tried various things but I always get PDOExceptions. But with calling PDO class directly the same code works…

Last edited by richard (2013-03-29 15:03)

Filip Procházka
Moderator | 4668
+
0
-

Why not simply

$stmt = $this->database->query($sql);
foreach ($stmt as $row) {
    dump($row);
}

Last edited by Filip Procházka (2013-03-29 15:47)

richard
Member | 60
+
0
-

Does not work.
Error: PDOException #IM001 SQLSTATE[IM001]: Driver does not support this function: driver doesn't support meta data

<?php
// this works
$sql = "select * from TABLE";
$dbh = new PDO('mssql:host=xxx;dbname=DB','xxx','xxx');
$stmt = $dbh->query($sql);
foreach ($stmt as $row) {
	dump($row);
}

// this has the error above
$sql = "select * from TABLE";
$stmt = $this->database->query($sql);
foreach ($stmt as $row) {
	dump($row);
}
?>
Filip Procházka
Moderator | 4668
+
0
-

Oh, I see now – you're using mssql, sorry about that. There are clearly missing some implementations, that might be important.

You should create an issue, or even better send a pullrequest, if you know how to solve this.

I've also found some older discussion on this topic, but unfortunatelly there is no solution provided.


I was googling a little, and It really seems like you shouldn't be using mssql with PDO, because it's just broken.

You should think about using better database, also read the warning on php.net

Last edited by Filip Procházka (2013-03-30 02:09)

David Grudl
Nette Core | 8082
+
0
-

As fix you can comment this line in file Nette\Database\Drivers\MsSqlDriver.php:

	public function isSupported($item)
	{
		//return $item === self::SUPPORT_COLUMNS_META;
	}
richard
Member | 60
+
0
-

Thank you both.

It works ok on the DB layer level. I am now running into more troubles with tweaking Nette, db layer, data grid and mssql. Mssql is not my choice, application is connecting to a DB filled by other system. I am opening a new topic on this – as this is rather to do with data grid now.

Thank you again.