Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

Zend\Db\Adapter\Exception\RuntimeException #103

Closed
mcl12345 opened this issue Oct 27, 2018 · 12 comments
Closed

Zend\Db\Adapter\Exception\RuntimeException #103

mcl12345 opened this issue Oct 27, 2018 · 12 comments
Labels

Comments

@mcl12345
Copy link

Hi,

I have an error when I followed the tutorial https://docs.zendframework.com/tutorials/getting-started/database-and-models/

capture d ecran de 2018-10-27 09-49-04

#0 /var/www/html/progressive_app/zf-tutorial/vendor/zendframework/zend-db/src/Adapter/Driver/Pdo/Pdo.php(255): Zend\Db\Adapter\Driver\Pdo\Connection->connect()
#1 /var/www/html/progressive_app/zf-tutorial/vendor/zendframework/zend-db/src/Sql/Sql.php(138): Zend\Db\Adapter\Driver\Pdo\Pdo->createStatement()
#2 /var/www/html/progressive_app/zf-tutorial/vendor/zendframework/zend-db/src/TableGateway/AbstractTableGateway.php(238): Zend\Db\Sql\Sql->prepareStatementForSqlObject(Object(Zend\Db\Sql\Select))
#3 /var/www/html/progressive_app/zf-tutorial/vendor/zendframework/zend-db/src/TableGateway/AbstractTableGateway.php(209): Zend\Db\TableGateway\AbstractTableGateway->executeSelect(Object(Zend\Db\Sql\Select))
#4 /var/www/html/progressive_app/zf-tutorial/vendor/zendframework/zend-db/src/TableGateway/AbstractTableGateway.php(196): Zend\Db\TableGateway\AbstractTableGateway->selectWith(Object(Zend\Db\Sql\Select))
#5 /var/www/html/progressive_app/zf-tutorial/module/Album/src/Model/AlbumTable.php(22): Zend\Db\TableGateway\AbstractTableGateway->select()
#6 /var/www/html/progressive_app/zf-tutorial/module/Album/src/Controller/AlbumController.php(22): Album\Model\AlbumTable->fetchAll()
#7 /var/www/html/progressive_app/zf-tutorial/vendor/zendframework/zend-mvc/src/Controller/AbstractActionController.php(78): Album\Controller\AlbumController->indexAction()
#8 /var/www/html/progressive_app/zf-tutorial/vendor/zendframework/zend-eventmanager/src/EventManager.php(322): Zend\Mvc\Controller\AbstractActionController->onDispatch(Object(Zend\Mvc\MvcEvent))
#9 /var/www/html/progressive_app/zf-tutorial/vendor/zendframework/zend-eventmanager/src/EventManager.php(179): Zend\EventManager\EventManager->triggerListeners(Object(Zend\Mvc\MvcEvent), Object(Closure))
#10 /var/www/html/progressive_app/zf-tutorial/vendor/zendframework/zend-mvc/src/Controller/AbstractController.php(105): Zend\EventManager\EventManager->triggerEventUntil(Object(Closure), Object(Zend\Mvc\MvcEvent))
#11 /var/www/html/progressive_app/zf-tutorial/vendor/zendframework/zend-mvc/src/DispatchListener.php(119): Zend\Mvc\Controller\AbstractController->dispatch(Object(Zend\Http\PhpEnvironment\Request), Object(Zend\Http\PhpEnvironment\Response))
#12 /var/www/html/progressive_app/zf-tutorial/vendor/zendframework/zend-eventmanager/src/EventManager.php(322): Zend\Mvc\DispatchListener->onDispatch(Object(Zend\Mvc\MvcEvent))
#13 /var/www/html/progressive_app/zf-tutorial/vendor/zendframework/zend-eventmanager/src/EventManager.php(179): Zend\EventManager\EventManager->triggerListeners(Object(Zend\Mvc\MvcEvent), Object(Closure))
#14 /var/www/html/progressive_app/zf-tutorial/vendor/zendframework/zend-mvc/src/Application.php(332): Zend\EventManager\EventManager->triggerEventUntil(Object(Closure), Object(Zend\Mvc\MvcEvent))
#15 /var/www/html/progressive_app/zf-tutorial/public/index.php(40): Zend\Mvc\Application->run()
#16 {main}

@Ocramius
Copy link
Member

Ocramius commented Oct 27, 2018 via email

@mcl12345
Copy link
Author

mcl12345 commented Oct 27, 2018

I tried to uncomment in /etc/php/7.2/apache2/php.ini
extension=pdo_mysql.so
extension=pdo.so
service restart apache2

But it doesn't work

@niners52
Copy link

I am getting same error. Any luck?

@froschdesign
Copy link
Member

@niners52
Please check your PHP installation, the extension for Sqlite is missing. See also: http://php.net/manual/en/pdo.installation.php

@froschdesign
Copy link
Member

froschdesign commented Feb 14, 2019

@mcl12345
MySQL is not needed for the Getting Started tutorial. You should look for Sqlite.

@niners52
Copy link

@niners52
Please check your PHP installation, the extension for Sqlite is missing. See also: http://php.net/manual/en/pdo.installation.php

This is what I get when I type in sqlite3-
SQLite version 3.11.0 2016-02-15 17:29:24
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database.

These were added to my php.ini file-
extension=pdo.so
extension=pdo_mysql.so

Is there something else I am missing? It looks like it is enabled.

@froschdesign
Copy link
Member

@niners52

These were added to my php.ini file-
extension=pdo.so
extension=pdo_mysql.so

MySQL is not needed for the Getting Started tutorial, only Sqlite!

@niners52
Copy link

I ran the installation for Sqlite and didn't get any errors.

@froschdesign
Copy link
Member

froschdesign commented Feb 14, 2019

You can test your Sqlite installation with a simple PHP script:

$db = new PDO('sqlite::memory:');
$db->query('CREATE TABLE `foobar` (`id` INTEGER)')->execute();

$stmt = $db->query("SELECT * FROM sqlite_master WHERE type='table'");
$stmt->execute();

var_dump($stmt->fetchAll());

The result is an array.


If this does not work, then unfortunately I can not help you either. I have never had a PHP installation without Sqlite and therefore I do not know how to configure it.
PDO and the PDO_SQLITE driver is enabled by default in PHP.

If you have other database support available in your PHP installation, then you should use it.

@niners52
Copy link

niners52 commented Feb 14, 2019

PHP Warning: Uncaught PDOException: could not find driver in php shell code:1

When I try and run the code you gave me. However I recently installed sqlite and below is what I got

Reading package lists... Done
Building dependency tree
Reading state information... Done
php-sqlite3 is already the newest version (2:7.2+69+ubuntu16.04.1+deb.sury.org+1).
Suggested packages:
sqlite-doc
The following NEW packages will be installed:
libsqlite0 sqlite
0 upgraded, 2 newly installed, 0 to remove and 159 not upgraded.
Need to get 154 kB of archives.
After this operation, 594 kB of additional disk space will be used.
Get:1 http://us.archive.ubuntu.com/ubuntu xenial/universe amd64 libsqlite0 amd64 2.8.17-12fakesync1 [139 kB]
Get:2 http://us.archive.ubuntu.com/ubuntu xenial/universe amd64 sqlite amd64 2.8.17-12fakesync1 [14.5 kB]
Fetched 154 kB in 0s (344 kB/s)
Selecting previously unselected package libsqlite0.
(Reading database ... 228729 files and directories currently installed.)
Preparing to unpack .../libsqlite0_2.8.17-12fakesync1_amd64.deb ...
Unpacking libsqlite0 (2.8.17-12fakesync1) ...
Selecting previously unselected package sqlite.
Preparing to unpack .../sqlite_2.8.17-12fakesync1_amd64.deb ...
Unpacking sqlite (2.8.17-12fakesync1) ...
Processing triggers for man-db (2.7.5-1) ...
Setting up libsqlite0 (2.8.17-12fakesync1) ...
Setting up sqlite (2.8.17-12fakesync1) ...
Processing triggers for libc-bin (2.23-0ubuntu10) ...

@geerteltink
Copy link
Member

@niners52 Shouldn't you install something like php7.3-sqlite3?

@froschdesign
Copy link
Member

Question seems to be answered. Closing.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

5 participants