Welcome to the nuBuilder forums!

Please register and login to view forums and other content only available to registered users.

Default database SQL

Post Reply
dgoadby
Posts: 12
Joined: Sat Jun 20, 2009 12:40 am
Location: Near Aberdaron in North Wales, UK

Default database SQL

Unread post by dgoadby »

For a new installation it would be nice if there was an installation SQL file with just the tables and records required to start off.

I have slowly stripped down the Sample system to create one and will freely submit it if required (is there a file section on the BB?).
Regards

David Goadby (North Wales, UK)
steven
Posts: 218
Joined: Mon Jun 15, 2009 10:03 am
Has thanked: 1 time

Re: Default database SQL

Unread post by steven »

dgoadby,

We have a procedure (an activity) which should be in the next build, that strips all the debtor stuff out and leaves you with a 'vanilla' version.

(Sorry about that.)

This is the code for it...

//objects
$sql = "DELETE FROM zzsys_object ";
$sql .= "WHERE sys_setup <> '1' ";
nuRunQuery($sql);

//system objects
$sql = "DELETE FROM zzsys_form ";
$sql .= "WHERE sys_setup <> '1' ";
nuRunQuery($sql);

//delete browse records not needed
$sql = "DELETE FROM zzsys_browse ";
$sql .= "WHERE sbr_zzsys_form_id NOT IN (SELECT zzsys_form_id FROM zzsys_form) ";
nuRunQuery($sql);

// delete all activities
$sql = "DELETE FROM zzsys_activity ";
nuRunQuery($sql);

//delete all images
nuRunQuery("DELETE FROM zzsys_image WHERE sim_group <> 'System'");

// flush acces level permissions
nuRunQuery("TRUNCATE TABLE zzsys_access_level_activity");
nuRunQuery("TRUNCATE TABLE zzsys_access_level_object ");
nuRunQuery("TRUNCATE TABLE zzsys_access_level ");

//clean up stuff
nuRunQuery("TRUNCATE TABLE zzsys_library");
nuRunQuery("TRUNCATE TABLE zzsys_user_group");
nuRunQuery("TRUNCATE TABLE zzsys_user");
nuRunQuery("TRUNCATE TABLE zzsys_user_log");
nuRunQuery("TRUNCATE TABLE zzsys_variable");
nuRunQuery("TRUNCATE TABLE zzsys_trap");
nuRunQuery("TRUNCATE TABLE zzsys_report_log");
nuRunQuery("TRUNCATE TABLE zzsys_session");

//delete all other tables
$sql = "SHOW TABLES";
$tables = mysql_query($sql);
while($row = mysql_fetch_row($tables)) {

$tblname = $row[0];
if (false == ereg("^zzsys_",$tblname)) {
mysql_query("DROP TABLE $tblname");
}
}

//delete lists
$listList = array();
$sql = "SELECT * FROM zzsys_object WHERE sob_all_type = 'dropdown' ";
$rs = nuRunQuery($sql);
while($obj = mysql_fetch_object($rs)) {
if (ereg("zzsys_list",$obj->sob_dropdown_sql)) {
$result = explode("'",$obj->sob_dropdown_sql);
$listList[] = $result[1];
}
}
$listList = array_unique($listList);
$listList = implode("','", $listList);
$listList = "'".$listList."'";
nuRunQuery("DELETE FROM zzsys_list WHERE sli_name NOT IN ($listList)");

echo "done, please log out, and log back in again";
If you like nuBuilder, how about leaving a nice review on SourceForge?
dgoadby
Posts: 12
Joined: Sat Jun 20, 2009 12:40 am
Location: Near Aberdaron in North Wales, UK

Re: Default database SQL

Unread post by dgoadby »

Thanks for that I will try it later today (UK time).

As I am still learning NuBuilder I might just strip out the SQL and run in directly.

Thanks

David
Regards

David Goadby (North Wales, UK)
Post Reply