Please login or register.

Login with username, password and session length
Advanced search  

News:

Latest sNews - sNews 1.7 - with its own forums - for discussion and user mods.

Pages: 1 [2]

Author Topic: [PACKAGE] sNews XE (eXtreme Edition):The fastest, most scalable edition of sNews  (Read 8735 times)

Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6019
  • Semantically Challenged
    • snews.ca
Re: Great work..
« Reply #15 on: October 15, 2008, 09:17:07 PM »

Great work..
But I think there are some bugs:

1- There is no CSS file.
2- I got 404 error with most links.
3- No installation form.
4- No design template
5- No sample SQLite database.

Please give us a complete list of all the files, by name, that came in the ZIP package you have.
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU

centered

  • Guest

This thread and package is pretty old but the code and techniques are still usable today. I have some code improvements below.  This code allows the SQLite DB version to be automatically switchable and adds some more functionality.

Code: [Select]
<?php

define
'__sqlite3'in_array'pdo_sqlite'get_loaded_extensions() ) );
define'__sqlite2'in_array'SQLite'get_loaded_extensions() ) );

$dbHandler FALSE;
$dbName $db['dbname']; // from configuration file or db array
$sqlFile 'sql file';
__dataPath 'path/to/your/db/folder';

// For SQLite 3
if ( __sqlite3 && !file_exists(__dataPath$dbName '_2.db') ) { 
function dbOpen() {
global $dbName$dbHandler;
$dbHandler = new PDO'sqlite:' __dataPath$dbName '_3.db' ) or die( dbError() );
return $dbHandler;
}

function dbError() {
global $dbHandler;
$error $dbHandler->errorInfo();
return $error['2'];
}

function dbQuery$query ) {
global $dbHandler;  
return $dbHandler->query$query );
}

function dbArrayQuery$query ) {
global $dbHandler;  
$result $dbHandler->query$query ); 
$result $result->fetchAll(PDO::FETCH_ASSOC);
return $result;
}

function dbFetchArray$query_result ) { 
return $query_result->fetch();
}

function dbFetchAssoc$query_result ) { 
return $query_result->fetch(PDO::FETCH_ASSOC);
}

function dbEscape$string ) {
if( function_exists'sqlite_escape_string' ) ) {
$string sqlite_escape_string$string );
} else {
$string str_replace"'""''"$string );
}
return $string;
}
} elseif ( 
__sqlite2 ) { 
function dbOpen() {
global $dbName$dbHandler;
$dbHandler sqlite_open__dataPath $dbName '_2.db'0666) or die( dbError() );
return $dbHandler;
}

function dbError() {
global $dbHandler;
return sqlite_error_stringsqlite_last_error$dbHandler ) );
}

function dbQuery$query ) {
global $dbHandler;  
return sqlite_query$dbHandler$query );
}

function dbArrayQuery$query ) {
global $dbHandler;    
return sqlite_array_query$dbHandler$querySQLITE_ASSOC ); 
}

function dbFetchArray$query_result ) { 
return sqlite_fetch_array$query_resultSQLITE_BOTH );
}

function dbFetchAssoc$query_result ) { 
return sqlite_fetch_array$query_resultSQLITE_ASSOC );
}

function dbEscape$string ) {
return sqlite_escape_string$string );
}
}

?>

Gotcha = sqlite num_row is not here.  PDO version for Sqlite 3 (rowCount) doesn't work too well so I scrapped it completely.  If you require a count, use the query:

select (count(id) from table where column = value) as num_rows....

Gotcha #2 - If you have a sqlite2 database running in a sqlite3 environment, the script would create a new sqlite 3 database.... to use the existing sqlite 2 database, I needed hack some changes like the underscore version # to differentiate the different versions.  If you wanted to know the version  you could use a fucntion like this (granted you have 1 db - note tested for more than 1):
Code: [Select]
function getdbVersion() {
$dir = opendir('data path');
if ($dir) {
while (false !== ($file = readdir($dir))) {
if ( preg_match('|\.db$|', $file)&& !is_dir($path.'/'.$file) ) {
$file = substr("$file",0,strpos($file, '.db'));
$version = substr($file, -1);
}
}
}
return $version;
}
$dbVersion = getdbVersion();
« Last Edit: September 13, 2009, 11:44:03 PM by equilni »
Logged

Cocor

  • Newbie
  • *
  • Karma: 0
  • Posts: 2

Hi can any one reupload this package? I want to try to use this project files. Thanks!
Logged

Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6019
  • Semantically Challenged
    • snews.ca

Hi can any one reupload this package? I want to try to use this project files. Thanks!

You may need to try contacting the author directly using the email address on the author's Profile Page. The author has not logged in here since October 2008.  8)
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU
Pages: 1 [2]