From d0a0d9e70b92e25ebcf9fc7851fb5b44030faa6f Mon Sep 17 00:00:00 2001
From: Jacek Kowalski <Jacek@jacekk.info>
Date: Mon, 17 Sep 2012 09:43:06 +0000
Subject: [PATCH] 1. Usunięcie pliku upgrade.php i przeniesienie jego funkcjonalności do pliku BotSession. 2. Uwzględnienie w/w zmiany w plikach INSTALL, UPGRADE, .htaccess 3. Usunięcie z pliku BUILD wzmianki o katalogu ./data/kino

---
 class/BotSession.php |   20 ++++++++++++++++++++
 1 files changed, 20 insertions(+), 0 deletions(-)

diff --git a/class/BotSession.php b/class/BotSession.php
index d273779..9099b8a 100644
--- a/class/BotSession.php
+++ b/class/BotSession.php
@@ -37,6 +37,24 @@
 			$this->PDO = new PDO('sqlite:'.BOT_TOPDIR.'/database/'.sha1($this->user).'.sqlite');
 			$this->PDO->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
 			$this->PDO->setAttribute(PDO::ATTR_ORACLE_NULLS, PDO::NULL_TO_STRING);
+			
+			$st = $this->PDO->query('SELECT value FROM data WHERE class=\'\' AND name=\'_version\'');
+			if($st->rowCount > 0) {
+				$row = $st->fetch(PDO::FETCH_ASSOC);
+				$version = (int)$row['value'];
+			}
+			else
+			{
+				$version = 0;
+			}
+			$st->closeCursor();
+			
+			if($version < 1) {
+				$this->PDO->query('UPDATE data SET class=\'kino\' WHERE class=\'\' AND name=\'kino\'');
+				$this->PDO->query('INSERT OR REPLACE INTO data (class, name, value) VALUES (\'\', \'_version\', 1)');
+				$version = 1;
+			}
+			
 			return;
 		}
 		
@@ -65,6 +83,8 @@
 			$this->PDO->beginTransaction();
 			$st = $this->PDO->prepare('INSERT OR REPLACE INTO data (class, name, value) VALUES (?, ?, ?)');
 			
+			$st->execute(array('', '_version', 1));
+			
 			foreach($files as $file) {
 				$data = unserialize(file_get_contents($file));
 				foreach($data as $name => $value) {

--
Gitblit v1.9.1