Location: PHPKode > projects > Simple Way to Usenet > config/CNF/cache_rpc.cnf.php
<?php
/**
 * This script contains the database information needed by a db object.
 * It will return as Array :
 * 	DBRef, the reference to the DB options set to use to connect to the database,
 * 	@see db.opt.php
 *  table, Table used by object to store his data.
 *  struct, An associative array with internal / dbfield associations.
 * func, An associative array with object method / dbmethod, dbqueries associations.
 * These informations are available to the object using the CORE::getcnf('object') method
 * 
 * @author  Benjamin Gillissen <hide@address.com>
 * 
 *	**************************************************************

	Copyright (C) 2007  Benjamin Gillissen
	
	This program is free software; you can redistribute it and/or
	modify it under the terms of the GNU General Public License
	as published by the Free Software Foundation; either version 2
	of the License, or (at your option) any later version.
	
	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details at:
	http://www.gnu.org/copyleft/gpl.html

 *	**************************************************************
 */

$o['tables']['status'] = configs::get('db', 'table_prefix').'cache_rpcstat';
$o['tables']['browser'] = configs::get('db', 'table_prefix').'cache_rpcbrw';
$o['tables']['rate'] = configs::get('db', 'table_prefix').'cache_didrate';
$o['tables']['delayed'] = configs::get('db', 'table_prefix').'cache_delayed';
									//intkeys		//tablefield
$o['structs']['status'] = Array(	'rpc'			=> 'rpc',
									'status'		=> 'status',
									'status_date'	=> 'status_date',
									'browser_date'	=> 'browser_date' 
							);

$o['structs']['browser'] = Array(	'rpc'		=> 'rpc',
									'hash'		=> 'hash',
									'catid'		=> 'catid',
									'title'		=> 'title',
									'engine'	=> 'engine',
									'id'		=> 'id',
									'data'		=> 'data',
									'date'		=> 'date',
									'size'		=> 'size',
									'lastview'	=> 'lastview'
							);
									//intkeys		//tablefield
$o['structs']['rate'] 	= Array(	'why'			=> 'why',
									'id'			=> 'id',
									'who'			=> 'who',
									'date'			=> 'date' 
							);
									//intkeys		//tablefield
$o['structs']['delayed'] = Array(	'rpc'			=> 'rpc',
									'id'			=> 'id',
									'unic'			=> 'unic',
									'date'			=> 'date' 
							);		
//DB vendor			//object method			  	  //db method	//db query
$o['mysql']= Array(	'iscached'			=> Array ('ispresent', 	"SELECT COUNT(*) FROM %table_status% WHERE %struct_status_rpc%='%arg_rpc%'"),
					'cacherpc'			=> Array ('insert', 	"INSERT INTO %table_status% (%struct_status_rpc%) VALUE ('%arg_rpc%')"),
					'set_status'		=> Array ('update', 	"UPDATE %table_status% SET %struct_status_status%='%arg_status%', %struct_status_status_date%='%arg_time%' 
																					WHERE %struct_status_rpc%='%arg_rpc%'"),
					'set_lastbrw'		=> Array ('update', 	"UPDATE %table_status% SET %struct_status_browser_date%='%arg_time%' 
																					WHERE %struct_status_rpc%='%arg_rpc%'"),
					'get_status'		=> Array ('getonefield',"SELECT %struct_status_status% FROM `%table_status%` WHERE %struct_status_rpc%='%arg_rpc%'"),
					'get_lastbrw'		=> Array ('getonefield',"SELECT %struct_status_browser_date% FROM `%table_status%` WHERE %struct_status_rpc%='%arg_rpc%'"),
					'get_statusdate'	=> Array ('getonefield',"SELECT %struct_status_status_date% FROM `%table_status%` WHERE %struct_status_rpc%='%arg_rpc%'"),

					'clean_browser' 	=> Array ('delete', 	"DELETE FROM %table_browser% WHERE %struct_browser_rpc%='%arg_rpc%' AND %struct_browser_lastview%<'%arg_limit%'"),
					'hash_iscached'		=> Array ('ispresent', 	"SELECT COUNT(*) FROM %table_browser% WHERE %struct_browser_rpc%='%arg_rpc%' AND %struct_browser_hash%='%arg_hash%' AND %struct_browser_catid%='%arg_catid%'"),
					'insert_item'		=> Array ('insert',		"INSERT INTO %table_browser% (%struct_browser_rpc%, %struct_browser_hash%, %struct_browser_catid%, %struct_browser_title%, %struct_browser_data%, %struct_browser_engine%, %struct_browser_id%, %struct_browser_date%, %struct_browser_size%, %struct_browser_lastview%) 
																					VALUES ('%arg_rpc%', '%arg_hash%', '%arg_catid%', '%arg_title%', '%arg_data%', '%arg_engine%', '%arg_id%', '%arg_date%', '%arg_size%', '%arg_time%')"),
					'update_item'		=> Array('update', 		"UPDATE %table_browser% SET %struct_browser_title%='%arg_title%', %struct_browser_lastview%='%arg_time%' WHERE %struct_browser_rpc%='%arg_rpc%' AND %struct_browser_hash%='%arg_hash%' AND %struct_browser_catid%='%arg_catid%' LIMIT 1"),
					'idisonrpc'			=> Array ('ispresent',	"SELECT COUNT(*) FROM %table_browser% WHERE %struct_browser_rpc%='%arg_rpc%' AND %struct_browser_id%='%arg_id%' AND %struct_browser_engine%='%arg_engine%'"),
					'listbycat'			=> Array ('fetchrow',	"SELECT * FROM %table_browser% WHERE %struct_browser_rpc%='%arg_rpc%' AND %struct_browser_catid%='%arg_catid%' ORDER BY %struct_browser_%arg_order%% %arg_way%"),

					'count_slot'		=> Array ('getcount',	"SELECT COUNT(*) FROM %table_rate% WHERE %struct_rate_date% >= '%arg_time%'"),
					'list_slot'			=> Array ('fetchrow',	"SELECT * FROM %table_rate% WHERE %struct_rate_date% >= '%arg_time%'"),
					'lock_slot'			=> Array ('insert',		"INSERT INTO %table_rate% (%struct_rate_date%, %struct_rate_why%, %struct_rate_id%, %struct_rate_who%) 
																					VALUES ('%arg_time%', '%arg_why%', '%arg_id%', '%arg_who%')"),
					'unlock_slot'		=> Array ('delete',		"DELETE FROM %table_rate% WHERE %struct_rate_date% < '%arg_time%'"),
					
					'delay_deloldest'	=> Array ('delete',		"DELETE FROM %table_delayed% WHERE 1 ORDER BY %table_delayed_date% ASC LIMIT 1"),
					'delay_delone'		=> Array ('delete',		"DELETE FROM %table_delayed% WHERE %struct_delayed_unic%='%arg_unic%' AND %struct_delayed_rpc%='%arg_rpc%' LIMIT 1"),
					'delay_getoldest'	=> Array ('getonerow', 	"SELECT * FROM %table_delayed% WHERE 1 ORDER BY %struct_delayed_date% ASC LIMIT 1"),
					'list_delayed'		=> Array ('fetchrow',	"SELECT * FROM %table_delayed% WHERE 1 ORDER BY %struct_delayed_date% ASC"),
					'list_delayedbyrpc'	=> Array ('fetchrow',	"SELECT * FROM %table_delayed% WHERE %struct_delayed_rpc%='%arg_rpc%' ORDER BY %struct_delayed_date% ASC"),
					'is_delayed'		=> Array ('ispresent', 	"SELECT COUNT(*) FROM %table_delayed% WHERE %struct_delayed_rpc%='%arg_rpc%' AND %struct_delayed_id%='%arg_id%'"),
					'add_delayed'		=> Array ('insert',		"INSERT INTO %table_delayed% (%struct_delayed_date%, %struct_delayed_rpc%, %struct_delayed_id%, %struct_delayed_unic%) 
																					VALUES ('%arg_time%', '%arg_rpc%', '%arg_id%', '%arg_unic%')"),
					
				);

$o['create']['mysql']['status'] = "CREATE TABLE `%table%` (`%struct_rpc%` int(3) NOT NULL,
  														`%struct_status%` longblob NULL,
  														`%struct_status_date%` bigint(16) NOT NULL,
  														`%struct_browser_date%` bigint(16) NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=utf8;";
$o['create']['mysql']['browser'] = "CREATE TABLE `%table%` (`%struct_rpc%` int(3) NOT NULL,
															`%struct_hash%` varchar(32) NOT NULL,
  															`%struct_catid%` varchar(2) NULL,
  															`%struct_title%` varchar(255) NOT NULL,
  															`%struct_engine%` enum('nbrid','nzbid') NOT NULL,
  															`%struct_id%` varchar(255) NOT NULL,
  															`%struct_size%` bigint(16) NOT NULL,
  															`%struct_date%` bigint(16) NOT NULL,
  															`%struct_lastview%` bigint(16) NOT NULL,
  															`%struct_data%` longblob NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=utf8;";
$o['create']['mysql']['rate'] 	= "CREATE TABLE `%table%` ( `%struct_why%` varchar(255) NOT NULL,
															`%struct_id%` 	varchar(255) NOT NULL,
															`%struct_who%` 	varchar(255) NOT NULL,
  														 	`%struct_date%` bigint(16) NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=utf8;";  															
$o['create']['mysql']['delayed']= "CREATE TABLE `%table%` ( `%struct_rpc%` 	int(3) NOT NULL,
															`%struct_id%` 	varchar(255) NOT NULL,
															`%struct_unic%`	varchar(32) NOT NULL,
  														 	`%struct_date%` bigint(16) NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=utf8;";  															

$o['sqlite']= Array();
$o['create']['sqlite'] = ""; 
return $o;
Return current item: Simple Way to Usenet