From 51b88e2b42efa667f5e40ff46292762a150474c5 Mon Sep 17 00:00:00 2001 From: PeaceCopathe Date: Mon, 15 Apr 2013 22:26:37 +0200 Subject: [PATCH] =?UTF-8?q?Cr=C3=A9ation=20Table=20auto=20table=20'entries?= =?UTF-8?q?'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Création de la tabe automatiquement si elle n'existe pas. Permet de repartir à zéro uniquement en supprimant le répertoire db. --- inc/db.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/inc/db.php b/inc/db.php index 705fc0c46..94777bb9c 100644 --- a/inc/db.php +++ b/inc/db.php @@ -10,12 +10,15 @@ class db { var $handle; - function __construct($path) { + function __construct($path) + { + $this->handle->exec('CREATE TABLE IF NOT EXISTS "entries" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL UNIQUE , "title" VARCHAR, "url" VARCHAR UNIQUE , "is_read" INTEGER DEFAULT 0, "is_fav" INTEGER DEFAULT 0, "content" BLOB)'); $this->handle = new PDO($path); $this->handle->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } - public function getHandle() { + public function getHandle() + { return $this->handle; } } \ No newline at end of file