Location: PHPKode > projects > Simple Way to Usenet > config/CNF/nzb.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['table'] = configs::get('db', 'table_prefix').'uplnzb';
						//intkeys	//tablefield
$o['struct'] = Array(	'nzbid'		=> 'nzbid',
						'catid'		=> 'catid',
						'file'		=> 'file' 
				);		
//DB vendor			//object method			  	  //db method	//db query
$o['mysql']= Array(	'exists'			=> Array ('ispresent', 	"SELECT COUNT(*) FROM `%table%` WHERE `%struct_nzbid%`='%arg_id%'"),
					'get_infos'			=> Array ('getonerow', 	"SELECT * FROM %table% WHERE `%struct_nzbid%`='%arg_id%'"),
					'get_idbyfile'		=> Array ('getonefield',"SELECT `%struct_nzbid%` FROM `%table%` WHERE `%struct_file%`='%arg_file%'"),
					'import_nzb'		=> Array ('insert',		"INSERT INTO `%table%` (`%struct_file%`, `%struct_catid%`) VALUES ('%arg_file%', '%arg_catid%')"),
					'remove_nzb'		=> Array ('delete', 	"DELETE FROM `%table%` WHERE `%struct_nzbid%`='%arg_id%' LIMIT 1"),
					'list_all'			=> Array ('fetchfield',	"SELECT `%struct_nzbid%` FROM `%table%` WHERE 1 ORDER BY `%struct_nzbid%` DESC LIMIT %arg_min%, %arg_max%"),
					'list_bycat'		=> Array ('fetchfield',	"SELECT `%struct_nzbid%` FROM `%table%` WHERE `%struct_catid%`='%arg_id%' ORDER BY `%struct_nzbid%` DESC LIMIT %arg_min%, %arg_max%"),
					'search_all'		=> Array ('fetchfield',	"SELECT `%struct_nzbid%` FROM `%table%` WHERE `%struct_file%` LIKE '%%arg_search%%' ORDER BY `%struct_nzbid%` DESC LIMIT %arg_min%, %arg_max% "),
					'search_bycat'		=> Array ('fetchfield',	"SELECT `%struct_nzbid%` FROM `%table%` WHERE `%struct_catid%`='%arg_id%' AND `%struct_file%` LIKE '%%arg_search%%' ORDER BY `%struct_nzbid%` DESC LIMIT %arg_min%, %arg_max%"),
					'count_all'			=> Array ('getcount',	"SELECT COUNT(*) FROM `%table%` WHERE 1"),
					'count_bycat'		=> Array ('getcount',	"SELECT COUNT(*) FROM `%table%` WHERE `%struct_catid%`='%arg_id%'"),
					'count_searchall'	=> Array ('getcount',	"SELECT COUNT(*) FROM `%table%` WHERE `%struct_file%` LIKE '%%arg_search%%'"),
					'count_searchbycat'	=> Array ('getcount',	"SELECT COUNT(*) FROM `%table%` WHERE `%struct_file%` LIKE '%%arg_search%%' AND `%struct_catid%`='%arg_id%'")					
				);

//TODO TOCHECK....
$o['sqlite']= Array('exists'			=> Array ('ispresent', 	"SELECT COUNT(*) FROM %table% WHERE %struct_nzbid%='%arg_id%'"),
					'get_infos'			=> Array ('getonerow', 	"SELECT * FROM %table% WHERE %struct_nzbid%='%arg_id%'"),
					'get_idbyfile'		=> Array ('getonefield',"SELECT %struct_nzbid% FROM %table% WHERE %struct_file%='%arg_file%'"),
					'import_nzb'		=> Array ('insert',		"INSERT INTO %table% (%struct_file%, %struct_catid%) VALUES ('%arg_file%', '%arg_catid%')"),
					'remove_nzb'		=> Array ('delete', 	"DELETE FROM %table% WHERE %struct_nzbid%='%arg_id%'"),
					'list_all'			=> Array ('fetchfield',	"SELECT %struct_nzbid% FROM %table% WHERE 1 ORDER BY %struct_nzbid% DESC LIMIT %arg_min%, %arg_max%"),
					'list_bycat'		=> Array ('fetchfield',	"SELECT %struct_nzbid% FROM %table% WHERE %struct_catid%='%arg_id%' ORDER BY %struct_nzbid% DESC LIMIT %arg_min%, %arg_max%"),
					'search_all'		=> Array ('fetchfield',	"SELECT %struct_nzbid% FROM %table% WHERE %struct_file% LIKE '%%arg_search%%' ORDER BY %struct_nzbid% DESC LIMIT %arg_min%, %arg_max% "),
					'search_bycat'		=> Array ('fetchfield',	"SELECT %struct_nzbid% FROM %table% WHERE %struct_catid%='%arg_id%' AND %struct_file% LIKE '%%arg_search%%' ORDER BY %struct_nzbid% DESC LIMIT %arg_min%, %arg_max%"),
					'count_all'			=> Array ('getcount',	"SELECT COUNT(*) FROM %table% WHERE 1"),
					'count_bycat'		=> Array ('getcount',	"SELECT COUNT(*) FROM %table% WHERE %struct_catid%='%arg_id%'"),
					'count_searchall'	=> Array ('getcount',	"SELECT COUNT(*) FROM %table% WHERE %struct_file% LIKE '%%arg_search%%'"),
					'count_searchbycat'	=> Array ('getcount',	"SELECT COUNT(*) FROM %table% WHERE %struct_file% LIKE '%%arg_search%%' AND %struct_catid%='%arg_id%'")					
				);
				
$o['create']['mysql'] = "CREATE TABLE `%table%` (
  								`%struct_nzbid%`	int(7) NOT NULL auto_increment,
  								`%struct_catid%` 	int(2) NOT NULL,
  								`%struct_file%` 	varchar(255) NOT NULL,  
  							PRIMARY KEY  (`%struct_nzbid%`) )
  							ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;";

$o['create']['sqlite'] = "CREATE TABLE %table% (
  								\"%struct_nzbid%\"		NUMERIC,
  								\"%struct_catid%\" 		NUMERIC,
  								\"%struct_file%\" 		TEXT );";
return $o;
Return current item: Simple Way to Usenet