S
S
Sergey Burduzha2017-09-11 14:26:00
SQLite
Sergey Burduzha, 2017-09-11 14:26:00

How to fix the error "Error: Class 'SQLite3' not found in /var/www/test.site/public_html/news/NewsDB.class.php on line 17"?

There is the following code

class NewsDB implements INewsDB{
    const DB_NAME = __DIR__.'/news.db';
    private $_db;

    function __get($name) {
      // TODO: Implement __get() method.
      if($name == 'db'){
        return $this->_db;
      }
      throw new Exception('Unknown property!!!');
    }

    function __construct() {
      $this->_db = new SQLite3(self::DB_NAME);
    }

    function __destruct() {
      // TODO: Implement __destruct() method.
      unset($this->_db);
    }

    function saveNews($title, $category, $description, $source) {
      // TODO: Implement saveNews() method.
    }

    function getNews() {
      // TODO: Implement getNews() method.
    }

    function deleteNews($id) {
      // TODO: Implement deleteNews() method.
    }
  }

I create a new object
$news = new NewsDB();
and get an error
Fatal error: Uncaught Error: Class 'SQLite3' not found in /var/www/test.site/public_html/news/NewsDB.class.php on line 17

Installed sqlite3 but it didn't solve the problem.
Do you have any ideas where to go next?
Thanks in advance.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Sanych, 2017-09-11
@serii81

sudo apt-get install php7.0-sqlite3
To see files starting with a dot (hidden files) in the terminal, you need to type ls -a
PhpStorm sees such files by default

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question