How to work with Sqlite and CMSMS 1.02

General project discussion. NOT for help questions.
Piratos

How to work with Sqlite and CMSMS 1.02

Post by Piratos »

At first download the original (big) adodb, because adodb lite has several big errors in his sqlite driver and did not work.
Copy the complete big adodb distribution in the folder lib/adodb_lite
Delete the folder modules/Search , because if you will install this module the max_execution time was reached and the server can hang.
60 seconds of max_execution time can be too low.
You can use module Piserach instead of module Search - Pisearch works.

Change a part of class.global.inc.php function GetDb to this:

        #return $dbinstance;
$db =& $this->db;
if ($config['dbms'] == 'sqlite')
                  $db->Execute("PRAGMA short_column_names = 1;");
return ($db);

These
if ($config['dbms'] == 'sqlite')
                  $db->Execute("PRAGMA short_column_names = 1;");
                 
are the additional lines.

Open the install.php and delete the comments near the sqlite options so it looks

if (extension_loaded('sqlite'))
{
echo 'SQLite';
$valid_database = true;
}


Now you can install the cmsms.

Instead of hostname and databasename you must use a full path with the databasename you are wishing, as example

c:\www\xampp\htdocs\102sqlite\cms.dat

The part of config.php looks after installation with this example so:

$config['dbms'] = 'sqlite';
$config['db_hostname'] = 'c:\www\xampp\htdocs\102sqlite\cms.dat';
$config['db_username'] = 'admin';
$config['db_password'] = 'admin';
$config['db_name'] = 'c:\www\xampp\htdocs\102sqlite\cms.dat';

By me sqlite works 50% faster as mysql and i have found no further problems.
Dee
Power Poster
Power Poster
Posts: 1197
Joined: Sun Mar 19, 2006 8:46 pm

Re: How to work with Sqlite and CMSMS 1.02

Post by Dee »

Piratos wrote: Change a part of class.global.inc.php function GetDb to this:

            #return $dbinstance;
      $db =& $this->db;
      if ($config['dbms'] == 'sqlite')
                  $db->Execute("PRAGMA short_column_names = 1;");
      return ($db);

These
if ($config['dbms'] == 'sqlite')
                  $db->Execute("PRAGMA short_column_names = 1;");
                 
are the additional lines.
That wont' work, it shows notices ($config is not defined there). Instead add

Code: Select all

			if ($config['dbms'] == 'sqlite')
			{
				$dbinstance->Execute("PRAGMA short_column_names = 1;");
			}
on line 177 of lib/classes/class.global.inc.php (function GetDb), right after

Code: Select all

			if (FALSE == $connect_result)
			{
				die('Database Connection failed');
			}
			$dbinstance->SetFetchMode(ADODB_FETCH_ASSOC);
I added the changes to SVN:
http://viewsvn.cmsmadesimple.org/viewsv ... 2&view=rev
Piratos

Re: How to work with Sqlite and CMSMS 1.02

Post by Piratos »

???

I think you need some glasses:

Code: Select all

function & GetDb()
	{
		#static $dbinstance;

		//Check to see if it hasn't been
		//instantiated yet.  If not, connect
		//and return it
		#if (!isset($dbinstance) && !isset($this->db))
		global $DONT_LOAD_DB;
		if (!isset($this->db) && !isset($DONT_LOAD_DB))
		{
			$config =& $this->GetConfig();
			$dbinstance = &ADONewConnection($config['dbms'], 'pear:date:extend:transaction');
			if (isset($config['persistent_db_conn']) && $config['persistent_db_conn'] == true)
			{
				$connect_result = $dbinstance->PConnect($config["db_hostname"],$config["db_username"],$config["db_password"],$config["db_name"]);
			}
			else
			{
				$connect_result = $dbinstance->Connect($config["db_hostname"],$config["db_username"],$config["db_password"],$config["db_name"]);
			}
			if (FALSE == $connect_result)
			{
				die('Database Connection failed');
			}
			$dbinstance->SetFetchMode(ADODB_FETCH_ASSOC);

			//$dbinstance->debug = true;
			if ($config['debug'] == true)
			{
				$dbinstance->debug = true;
				#$dbinstance->LogSQL();
			}

			$this->db =& $dbinstance;

		}

		#return $dbinstance;
		$db =& $this->db;
		 if ($config['dbms'] == 'sqlite')
		 {
                   $db->Execute("PRAGMA short_column_names = 1;");
                  
                 }
		return ($db);
	}
i have installed the cmsms nearly 50 times with this and sqlite.
Dee
Power Poster
Power Poster
Posts: 1197
Joined: Sun Mar 19, 2006 8:46 pm

Re: How to work with Sqlite and CMSMS 1.02

Post by Dee »

My eyes are fine and my PHP's error reporting level is set to show notices:
Notice: Undefined variable: config in /path/to/cmsms/lib/classes/class.global.inc.php on line 189
Last edited by Anonymous on Sun Oct 08, 2006 11:02 pm, edited 1 time in total.
Piratos

Re: How to work with Sqlite and CMSMS 1.02

Post by Piratos »

php as interpreter defines variables if you should use one and it get a Null value.

so if config is not loaded with getconfig  the database connection exists.

and so this statement  if ($config['dbms'] == 'sqlite') is always false  , because $config['dbms'] is empty and the pragma statement are never in action.

if the database connection does not exists ($config['dbms'] gets the value of the config.php and if the driver is sqlite  the prgama statement works.

take a look with or not with glasses in the php handbook.

and so since 3 days i work very fine with cmsms 1.02 and sqlite.
Piratos

Re: How to work with Sqlite and CMSMS 1.02

Post by Piratos »

Addtional information - my standard of error_reporting is error_reporting  =  E_ALL & ~E_NOTICE
and  NO error was shown like you reported.

if a set it to  error_reporting = E_ALL & ~E_NOTICE | E_STRICT i will have many messages of Strict standards but no error and no error or warning like you reported.

Debugging - No error 
Dee
Power Poster
Power Poster
Posts: 1197
Joined: Sun Mar 19, 2006 8:46 pm

Re: How to work with Sqlite and CMSMS 1.02

Post by Dee »

Piratos wrote: Addtional information - my standard of error_reporting is error_reporting  =  E_ALL & ~E_NOTICE
and  NO error was shown like you reported.
Try E_ALL, it will show the notice(s).  E_ALL & ~E_NOTICE means PHP will show all errors, except for notices.
Piratos

Re: How to work with Sqlite and CMSMS 1.02

Post by Piratos »

I know what you mean but notice is nothing, no warning , no error  it is only a little helper.
Dee
Power Poster
Power Poster
Posts: 1197
Joined: Sun Mar 19, 2006 8:46 pm

Re: How to work with Sqlite and CMSMS 1.02

Post by Dee »

Maybe it would be of more use if you were to test the changes made to SVN to see if they work (I think they should):
http://viewsvn.cmsmadesimple.org/viewsv ... p?rev=3462
Piratos

Re: How to work with Sqlite and CMSMS 1.02

Post by Piratos »

Make it shorter:

Code: Select all

	function & GetDb()
	{
		global $DONT_LOAD_DB;
		if (!isset($this->db) && !isset($DONT_LOAD_DB))
		{
			$config =& $this->GetConfig();
			$this->db = &ADONewConnection($config['dbms'], 'pear:date:extend');
			if (isset($config['persistent_db_conn']) && $config['persistent_db_conn'] == true)
                             $connect_result = $this->db->PConnect($config["db_hostname"],$config["db_username"],$config["db_password"],$config["db_name"]);
			else
                             $connect_result = $this->db->Connect($config["db_hostname"],$config["db_username"],$config["db_password"],$config["db_name"]);
			if (FALSE == $connect_result) die('Database Connection failed');
			$this->db->SetFetchMode(ADODB_FETCH_ASSOC);
			if ($config['debug'] == true) $this->db->debug = true;
		        if ($config['dbms'] == 'sqlite') $this->db->Execute("PRAGMA short_column_names = 1;");
		}
		return $this->db;
	}
and don't forget  adodb lite with sqlite does not work !!
Last edited by Piratos on Mon Oct 09, 2006 5:29 pm, edited 1 time in total.
Piratos

Re: How to work with Sqlite and CMSMS 1.02

Post by Piratos »

Here one of the best values on a free webspace page Home
Generated in 0.175264 seconds by CMS Made Simple (not cached) using SQL queries and 5341856 bytes of memory
You can see CMSMS 1.02 with Sqlite and BIG Adodb in action  here : http://piratos.byethost33.com/cmsms/
Dee
Power Poster
Power Poster
Posts: 1197
Joined: Sun Mar 19, 2006 8:46 pm

Re: How to work with Sqlite and CMSMS 1.02

Post by Dee »

How come ADOdb Lite and SQLite won't work? ADOdb Lite does have drivers for SQLite.
I'm trying to get CMSMS to work with SQLite and full ADOdb, but keep getting "Could not create a table. Verify that the user has privileges to create tables in the given database.". Any ideas?
Piratos

Re: How to work with Sqlite and CMSMS 1.02

Post by Piratos »

How come ADOdb Lite and SQLite won't work
Yup there are drivers but there hav several bugs, i count 5 and than i decided to test it with Adodb full - and it works.
Piratos

Re: How to work with Sqlite and CMSMS 1.02

Post by Piratos »

i have reported this to the developer of adodb lite and he do his best to solve the driver problems.
Dee
Power Poster
Power Poster
Posts: 1197
Joined: Sun Mar 19, 2006 8:46 pm

Re: How to work with Sqlite and CMSMS 1.02

Post by Dee »

OK, untill it's fixed we'll make the install script show an error if ADOdb Lite is used:
http://viewsvn.cmsmadesimple.org/viewsv ... 7&view=rev
Post Reply

Return to “General Discussion”