Location: PHPKode > projects > MJGUEST > mjguest/database/sqlite/driver_pdo.php
<?php
	
	/*
	+----------------------------------------------------------------
	|
	|	MJGUEST
	|	=============================================================
	|	Copyright (c) 2002-2008 Giacomo "mdsjack" Menni
	|	Terms of agreement and support at www.mdsjack.bo.it
	|
	+----------------------------------------------------------------
	|	[ DATABASE MODULE ]
	|	Database driver (PDO-SQLite3 Driver)
	+----------------------------------------------------------------
	*/
	
	final class db_driver extends PDO_driver
	{
		public $driver = 'PDO-SQLite'; # const
		
		protected $dns;
		
		protected $questions = array
		(	'truncate'			=> 'DELETE FROM %s'
		,	'optimize'			=> 'VACUUM %s'
		,	'row_delete'		=> 'DELETE FROM %s WHERE %s=\'%s\''
		,	'row_count'			=> 'SELECT COUNT(*) FROM %s'
		,	'row_add'			=> 'INSERT INTO %s VALUES()'
		,	'settings_load'		=> 'SELECT * FROM [TBL=settings]'
		,	'settings_update'	=> 'UPDATE [TBL=settings] SET adminpass=\'%s\', adminmail=\'%s\', timezone=%d, dateformat=\'%s\', theme=\'%s\', entriesxpage=%u, wordfilter=%b, title=\'%s\', namelen=%u, msglen=%u, emoticons=%u, avatars_maxkilobytes=%u, redirectscreen=%b, notifynewentry=%b, captcha=%b, messenger=%b, entry_approval=%b, mod_account=%b, modpass=\'%s\', modmail=\'%s\', rating=%b, banned=\'%s\', name_admin=\'%s\', name_mod=\'%s\' '
		,	'settings_restore'	=> 'UPDATE [TBL=settings] SET adminpass=\'password\', adminmail=\'hide@address.com\', timezone=0, dateformat=\'d.m.Y h:ia\', theme=\'theme-hera\', entriesxpage=10, wordfilter=1, title=\'Website name\', namelen=15, msglen=500, emoticons=5, avatars_maxkilobytes=0, redirectscreen=1, notifynewentry=0, captcha=0, messenger=1, entry_approval=0, mod_account=0, modpass=\'moderator\', modmail=\'hide@address.com\', rating=1, banned=\'\', name_admin=\'\', name_mod=\'\' '
#		,	'settings_restore'	=> 'INSERT INTO [TBL=settings] (adminpass) VALUES(\'password\')' #all fields reset to default value
		,	'entry_add'			=> 'INSERT INTO [TBL=entries] VALUES(NULL, \'%s\', %b, \'%s\',\'%s\', %u, \'%s\', \'%s\', \'%s\', \'%s\',\'%s\',\'%s\',\'%s\', \'\', %b, %u)'
		,	'entry_get_set'		=> 'SELECT id, ip, pvt, name, country, datetime, message, dir, email, web, chat, uin, LENGTH(avatar) AS avatar, reply, approved, rating FROM [TBL=entries] %§ ORDER BY id DESC LIMIT %1$u,%2$u'
		,	'entry_get_one'		=> 'SELECT pvt, name, country, message, dir, email, web, chat, uin, LENGTH(avatar) AS avatar, reply, rating FROM [TBL=entries] WHERE id=%u'
		,	'entry_edit'		=> 'UPDATE [TBL=entries] SET pvt=\'%b\', name=\'%s\', country=\'%s\', message=\'%s\', dir=\'%s\', email=\'%s\', web=\'%s\', chat=\'%s\', uin=\'%s\', rating=%u %§ WHERE id=%u'
		,	'get_avatar'		=> 'SELECT avatar FROM [TBL=entries] WHERE id=%u'
		,	'check_flood'		=> 'SELECT MAX(datetime) FROM [TBL=entries] WHERE ip=\'%s\''
		,	'reply_save'		=> 'UPDATE [TBL=entries] SET reply=\'%s\' WHERE id=%u'
		,	'approve'			=> 'UPDATE [TBL=entries] SET approved=1 WHERE id=%u'
		,	'ban_guest'			=> 'UPDATE [TBL=settings] SET banned=\'%s\''
		,	'rating_stats'		=> 'SELECT AVG(rating) AS avg, COUNT(rating) AS tot FROM [TBL=entries] WHERE rating != 0'
		);
		
		function __construct()
		{
			parent::__construct();
			
			$this->id = new PDO('sqlite:'.mjguest_basedir.db_host.(!db_name ? 'database.db' : db_name.'.db'));
			
			return true;
		}
	}

?>
Return current item: MJGUEST