Location: PHPKode > projects > MJGUEST > mjguest/database/mysql/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-MySQL4/5 Driver)
	+----------------------------------------------------------------
	*/
	
	final class db_driver extends PDO_driver
	{
		public $driver = 'PDO-MySQL'; # const
		protected $dns;
		
		protected $questions = array
		(	'truncate'			=> 'TRUNCATE %s'
		,	'optimize'			=> 'OPTIMIZE TABLE %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=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(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 %u,%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('mysql:host='.db_host.';port='.db_port.';dbname='.db_name, db_user, db_pass, array(PDO::ATTR_PERSISTENT => true));
			
			return true;
		}
	}

?>
Return current item: MJGUEST