1
nayeem
mass update on config table at module install time
  • 2004/6/14 13:59

  • nayeem

  • Just popping in

  • Posts: 44

  • Since: 2004/1/3 1


is there a way to mass update a lot of configuration options to the 'config' table during install. I am writing a module that has a lot of configuration and it will be a pain to put them all in the xoops_version.php one by one.
if there is a way to run them as queries that would be most ideal.

also i need to run some extra queries after my tables are created, anyone knows how i can do it during installtime? the xoops_version.php doesnt seem to leave any option for that.

thanks in advance.

nsm

2
Dave_L
Re: mass update on config table at module install time
  • 2004/6/14 14:23

  • Dave_L

  • XOOPS is my life!

  • Posts: 2277

  • Since: 2003/11/7


1) I don't understand why you don't want to put the information in xoops_version.php. That only has to be done once.

2) http://wiki.xoops.org/wakka.php?wakka=XoopsModuleOnInstall

3
ackbarr
Re: mass update on config table at module install time

Also your SQL script can include INSERT and UPDATE commands after the CREATE TABLE commands have executed. Just like the CREATE TABLE commands, omit the table prefix from the commands.

4
nayeem
Re: mass update on config table at module install time
  • 2004/6/14 14:46

  • nayeem

  • Just popping in

  • Posts: 44

  • Since: 2004/1/3 1


Thanks for the replies.

One part of my problem can be now solved if I put the queries updating my own tables inside the sql file in the module.

However, for inserting into the 'config' table using queries, how would I read the module id at install time? even if i run from the postinstall function like dave suggested on (2).

If this is really not possible I guess I will just put them all in the xoops_version.php...

nsm

5
ackbarr
Re: mass update on config table at module install time

You would have to use the post install function. The succeeding code snippet displays how to get the module ID of any installed module by module name:
$hModule =& xoops_gethandler('module');
$module =& $hModule->getByDirname('myModuleName');
$id $module->getVar('mid');


6
ackbarr
Re: mass update on config table at module install time

just re-read the onInstall docs. The newly created module object is sent into this function so to get the module ID you'd need to do:
$id $module->getVar('mid');

7
nayeem
Re: mass update on config table at module install time
  • 2004/6/14 15:28

  • nayeem

  • Just popping in

  • Posts: 44

  • Since: 2004/1/3 1


thanks.

is there a XOOPS standard way of running queries or would it be something like the following by using the db object :
$xoopsDB->execute('insert into config...');

Where can i find the code that actually runs the sql file thats passed on the xoops_version.php. It would help to figure out some of the syntax if i can find that.

nsm

8
Mithrandir
Re: mass update on config table at module install time

$xoopsDB->query('SQL Statement');

The file you are interested in is modules/system/admin/modulesadmin/main.php (I think... possibly it's modulesadmin.php)

It's a long file with many clauses, so you may have to do quite some code reading before you find what you are looking for.

9
ackbarr
Re: mass update on config table at module install time

use $xoopsDB->query('SQL QUERY');

XOOPS module installation code:
/modules/system/admin/modulesadmin/modulesadmin.php in the function xoops_module_install

in XOOPS 2.0.6 look at ~line 380, you should be able to backtrack the code from there.

* looks like Mithy beat me to the punch

10
nayeem
Re: mass update on config table at module install time
  • 2004/6/14 16:27

  • nayeem

  • Just popping in

  • Posts: 44

  • Since: 2004/1/3 1


thanks guys.
i seem to be running into some strange problem when trying to create the tables in the first place however. It doesnt create the tables and doesnt give any error messages either. Below is what my sql file looks like :
Quote:

the installer shows the following error, i am guessing its to do with how sqlutility.php breaks the sql file up?... is there something obvious i am missing?
Quote:

SQL file found at /Users/admin/Sites/x2/html/modules/il/sql/mysql.sql.
Creating tables...
Module data inserted successfully. Module ID: 15

the xoops_version.php code is like this :
Quote:

$modversion['sqlfile']['mysql'] = "sql/mysql.sql";
//$modversion['sqlfile']['postgresql'] = "sql/pgsql.sql";

// Tables created by sql file (without prefix!)
$modversion['tables'][0] = "IL_albums";
$modversion['tables'][1] = "IL_categories";
$modversion['tables'][2] = "IL_photo_categories";
$modversion['tables'][3] = "IL_comments";
$modversion['tables'][4] = "IL_photos";
$modversion['tables'][7] = "IL_rating";


the sql creates a table fine if i only have one table.

Login

Who's Online

827 user(s) are online (57 user(s) are browsing Support Forums)


Members: 0


Guests: 827


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Jul 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits