Answer the question
In order to leave comments, you need to log in
How to work with .db tables?
Hello.
The point is this. I want to use the database in the datebase.db file I
did not encounter this and the problems crawled out at an early stage. Need a specific datebase.db file?
I created an empty one. Connected like this:
try {
$db = new PDO("sqlite:database.db");
}
catch(PDOException $e) {
echo "Нет соединения с базой данных";
}
$rows = $db->exec("CREATE TABLE `testing`(
id INT PRIMARY KEY AUTO_INCREMENT,
fname VARCHAR(20) NOT NULL DEFAULT '',
email VARCHAR(50) NOT NULL DEFAULT '',
money INT NOT NULL DEFAULT 0) ENGINE=InnoDB;");
$rows = $db->exec("INSERT INTO `testing` VALUES
(null, 'Ivan', '[email protected]', 15000),
(null, 'Petr', '[email protected]', 411000),
(null, 'Vasiliy', '[email protected]', 1500000)
");
Answer the question
In order to leave comments, you need to log in
ENGINE=InnoDB in your query refers to the MySQL DBMS. There is no such thing in Sqlite.
In general, it would be nice to enable correct error handling, for example, like this:
try {
$dbh = new PDO("sqlite:database.db");
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$rows = $dbh->exec("...");
} catch (PDOException $e) {
echo 'Error: ' . $e->getMessage();
}
What are you expecting?? What should be happening??
Seriously, if this is all the code that you have, then you will not have anything in the output, but if the trouble is that the file is not being created, you probably do not have the rights to create it. The biggest problem for you will be the rights, the rest will be in the output if you have it configured.
One problem is that you are creating a SQLite database and you are trying to use the query syntax for MySQL.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question