ezSQL / ezsql

PHP class to make interacting with a database ridiculusly easy
http://ezsql.github.io/ezsql
GNU Lesser General Public License v3.0
866 stars 291 forks source link

Initializing database error #187

Closed similarduckweed closed 4 years ago

similarduckweed commented 4 years ago

erro: "
Fatal error: Uncaught ezsql\Exception\ContainerException: Can not resolve class dependency dsn in D:\phpstudy_pro\WWW\duwell\vas-cas-admin\common\vendor\ezsql\ezsql\lib\DInjector.php:144 Stack trace:

0 D:\phpstudy_pro\WWW\duwell\vas-cas-admin\common\vendor\ezsql\ezsql\lib\DInjector.php(112): ezsql\DInjector->getDependencies(Array, Array)

1 D:\phpstudy_pro\WWW\duwell\vas-cas-admin\common\vendor\ezsql\ezsql\lib\DInjector.php(50): ezsql\DInjector->resolve('PDO', Array)

2 D:\phpstudy_pro\WWW\duwell\vas-cas-admin\common\vendor\ezsql\ezsql\lib\Database.php(50): ezsql\DInjector->get('PDO', Array)

3 D:\phpstudy_pro\WWW\duwell\vas-cas-admin\login\login.php(12): ezsql\Database::initialize('PDO', Array)

4 {main}

thrown in D:\phpstudy_pro\WWW\duwell\vas-cas-admin\common\vendor\ezsql\ezsql\lib\DInjector.php on line 144
"

TheTechsTech commented 4 years ago

You have not provide any necessary info, none of the required, no code snippet, no bug report.

As such look over the tests, then reopen.

similarduckweed commented 4 years ago

`<?php

require '../common/vendor/autoload.php'; use ezsql\Database; //test $sql = "select account from user where id=1"; $db= Database::initialize('PDO', ['mysql:host=localhost;dbname=duwell;port=3306','root','root']);

$data=$db->query($sql);

similarduckweed commented 4 years ago

Is there a problem connecting to the database?

TheTechsTech commented 4 years ago

require '../common/vendor/autoload.php';

What is that? Look at the readme.md examples. You are getting the correct error, there is no error. You are using composer autoload wrong.

If that was the case none of the tests would be passing.