Location: PHPKode > projects > MJGUEST > mjguest/database/pgsql/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-PgSQL8 Driver)
	+----------------------------------------------------------------
	*/
	
	final class db_driver extends PDO_driver
	{
		public $driver = 'PDO-PgSQL'; # const
		protected $dns;
		
		protected $questions = array
		(	'truncate'			=> 'TRUNCATE %s'
		,	'optimize'			=> 'VACUUM %s'
		,	'row_delete'		=> 'DELETE FROM %s WHERE %s=\'%s\''
		,	'row_count'			=> 'SELECT COUNT(*) FROM %s'
		,	'row_add'			=> 'INSERT INTO %s DEFAULT 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\'%b\', title=\'%s\', namelen=\'%u\', msglen=\'%u\', emoticons=\'%u\', avatars_maxkilobytes=\'%u\', redirectscreen=B\'%b\', notifynewentry=B\'%b\', captcha=B\'%b\', messenger=B\'%b\', entry_approval=B\'%b\', mod_account=B\'%b\', modpass=\'%s\', modmail=\'%s\', rating=B\'%b\', banned=\'%s\', name_admin=\'%s\', name_mod=\'%s\' '
		,	'settings_restore'	=> 'UPDATE [TBL=settings] SET adminpass=DEFAULT, adminmail=DEFAULT, timezone=DEFAULT, dateformat=DEFAULT, theme=DEFAULT, entriesxpage=DEFAULT, wordfilter=DEFAULT, title=DEFAULT, namelen=DEFAULT, msglen=DEFAULT, emoticons=DEFAULT, avatars_maxkilobytes=DEFAULT, redirectscreen=DEFAULT, notifynewentry=DEFAULT, captcha=DEFAULT, messenger=DEFAULT, entry_approval=DEFAULT, mod_account=DEFAULT, modpass=DEFAULT, modmail=DEFAULT, rating=DEFAULT, banned=DEFAULT, name_admin=DEFAULT, name_mod=DEFAULT '
		,	'entry_add'			=> 'INSERT INTO [TBL=entries] VALUES(DEFAULT, \'%s\', B\'%b\', \'%s\',\'%s\', %u, \'%s\', \'%s\', \'%s\', \'%s\',\'%s\',\'%s\',\'%s\', \'\', B\'%b\', \'%u\')'
		,	'entry_get_set'		=> 'SELECT id, ip, pvt, name, country, datetime, message, dir, email, web, chat, uin, CHAR_LENGTH(avatar) AS avatar, reply, approved, rating FROM [TBL=entries] %§ ORDER BY id DESC OFFSET %u LIMIT %u'
		,	'entry_get_one'		=> 'SELECT pvt, name, country, message, dir, email, web, chat, uin, CHAR_LENGTH(avatar) AS avatar, reply, rating FROM [TBL=entries] WHERE id=%u'
		,	'entry_edit'		=> 'UPDATE [TBL=entries] SET pvt=B\'%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=B\'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('pgsql:host='.db_host.' port='.db_port.' dbname='.db_name.' user='.db_user.' password='.db_pass);
			
			return true;
		}
	}

?>
Return current item: MJGUEST