Reply New Topic
2010/3/4 17:59:23
#1
Offline
Home away from home

icms_version IPF & SQL - A Little Different?

I did a search for "icms_version database" and didn't find anything, so thought I'd ask.

Now I'm playing catch up here and think I have this correct so I'm either looking for clarification or confirmation.

Traditionally the SQL for a module would be held in an SQL file usually located in "/sql/mysql.sql" and the following would import that file on installation of a module, in the case of myalbum something like:

// SQL
$modversion['sqlfile']['mysql'] = "sql/mysql.sql";
$modversion['tables'][0] = "cat";
$modversion['tables'][1] = "comments";
$modversion['tables'][2] = "photos";
$modversion['tables'][3] = "text";
$modversion['tables'][4] = "votedata";

Now I presume a move has been made so that module developers no longer need to write sql?

I see now that the above would be done something like:

$modversion['object_items'][$i] = 'cat';
$modversion["tables"] = icms_getTablesArray($modversion['dirname'], $modversion['object_items']);

And then in the class folder you would have a file named cat.php (And one for every table?) which would have something similar to:

$this->quickInitVar('title', XOBJ_DTYPE_TXTBOX, false);
$this->hideFieldFromForm('cid');

Am I on the right lines here?

If so, do we have any documentation yet about the XOBJ_DTYPE which ones to use, what arguments a function will take, etc?

I been catching up with the IPF videos and some of the other stuff on site like Steves fantastic blog/tutorials but is there anything available which is simplistic but deep?

Thanks


2010/3/4 19:28:34
#2
Offline
Home away from home

Re: icms_version IPF & SQL - A Little Different?

Where did you see this new system? I'm still using dark ages modules so I haven't tripped over it yet.

Does it simplify things, or does it make life more complicated?


2010/3/4 22:34:07
#3
Offline
Home away from home

Re: icms_version IPF & SQL - A Little Different?

I just looked at the modules packed with ICMS 1.2 final. Profile and Content. (in the icms_version.php initially)

I can see the purpose of it and yeah I think in theory it is a good thing, it would mean that no module developers mess with MySQL and thus leave it to the core. Should the core use different DBs like Cassandra or the Microsoft equivalent of SQL then it means all modules would still be compatible with this method as the module makes use of the IPF. I suppose something like DB drivers could then be made for ICMS.

Is it easier?

With documentation I believe so, but I did sit and scratch my head for a while and then followed the code back. I just couldn't figure out where the SQL file was at first, I suppose this was because I was looking to hard for something that was traditionally there.

I'm hoping for some clarification or confirmation about this.


2010/3/4 23:01:49
#4
Offline
Home away from home

Re: icms_version IPF & SQL - A Little Different?

Madfish.

Here is the method for quickInitvar:

function quickInitVar($key, $data_type, $required=false, $form_caption='', $form_dsc='', $value = null)

I think the Vars there pretty much explain what I was looking for.


2010/3/4 23:06:19
#5
Offline
Home away from home

Re: icms_version IPF & SQL - A Little Different?

Are we talking about imBuilding here?
Imbuilding is a module with which you can ... build modules :lmao:

It makes life easier.
What you can do is build a basic module and then still modify it afterwards.

It makes use of Impress Persistable Framework, IPF

Watch the videos on youtube
http://www.youtube.com/impresscms

We also have a couple of threads going here on the forum about imbuilding.


2010/3/4 23:57:26
#6
Offline
Home away from home

Re: icms_version IPF & SQL - A Little Different?

I'm aware of imBuilding and used it just to compare but personally to understand something, I must become something. lol

In other words its cool that you can have something built for you but its cooler to achieve the same result building it from scratch and understanding how. Understanding how the DB is built on install, how it can be upgraded and so on is cool stuff to know.


2010/3/5 1:48:51
#7
Offline
Home away from home

Re: icms_version IPF & SQL - A Little Different?

Ok if it somehow helps with database abstraction I can see how that might be of interest.

But there's a lot to be said for the old SQL file IMHO. It's so clean and simple that a monkey could understand it. That's a good thing.


2010/3/5 5:51:11
#8
Offline
Home away from home

Re: icms_version IPF & SQL - A Little Different?

To give a simple answer to your question Tom: Yes. That's exactly how it works.

First you define the tables in the icms_version.php file by declaring the objects the module uses. For each object (for which the information will be stored in tables) there is a .php file in the class folder. In these class files you will always find two classes. One for the object iteself, the other one to serve as a handler for that object type.

In the constructor of the object class you can define the variable you want to use in the object. A variable can be persistent (a column will be created for it in on the database layer) or non-persistent (no column will be created). Each variable needs to have a data type specified.

For the data types available in IPF, simply search the core code for XOBJ_DTYPE_* and you will find a list of available data types.

And finally, there is no way to specifiy indexes or even foreign keys or something like that right now. However, there's a ticket to handle that lack of functionallity.

I hope this helps. Let me know if you need further information.

_________________
the german icms website : www.impresscms.de

2010/3/5 8:49:40
#9
Offline
Home away from home

Re: icms_version IPF & SQL - A Little Different?

That does help, thank you.

Quote:

And finally, there is no way to specifiy indexes or even foreign keys or something like that right now. However, there's a ticket to handle that lack of functionallity.



I had noticed this, I was looking at how to ensure a table (key) would auto increment in the DB, which was why I originally asked about the arguments it would take.

Thanks again.


2010/3/5 9:14:39
#10
Offline
Home away from home

Re: icms_version IPF & SQL - A Little Different?

In case you want to have indexes, you can create them in the after install process manually.

_________________
the german icms website : www.impresscms.de

2010/3/5 9:46:38
#11
Offline
Home away from home

Re: icms_version IPF & SQL - A Little Different?

When you say in the after install process, I presume by this you mean with some php and sql to alter the table? Perhaps with the onInstall/OnUpgrade file defined in the icms_version.php?


2010/3/5 10:49:09
#12
Offline
Home away from home

Re: icms_version IPF & SQL - A Little Different?

Absolutely correct

_________________
the german icms website : www.impresscms.de

2010/3/5 15:01:17
#13
Offline
Home away from home

Re: icms_version IPF & SQL - A Little Different?

Thanks Phoenyx.


2010/3/5 18:18:50
#14
Offline
Home away from home

Re: icms_version IPF & SQL - A Little Different?

This thread is quite helpful for developers making the transition from the 'old school' way - perhaps this could be a topic for a video/tutorial: "If you're used to doing this, now do this"

_________________

Steve Twitter: @skenow Facebook: Steve Kenow


2010/3/5 18:34:22
#15
Offline
Home away from home

Re: icms_version IPF & SQL - A Little Different?

That would be helpful. I'm having some minor issues with it but I think its just because I'm still in a mind set, perhaps making it harder than need be.

I can install a module, but not tables insert.
I can uninstalls the module, If there are tables it will remove them. (I insert the tables through PHPMyAdmin after install).

I'm pretty sure its something I'm missing or a type although I can't see it.

So I'll ask, once assigned to the variables in icms_version.php :

$modversion['object_items'][0] = 'table1'; $modversion["tables"] = icms_getTablesArray($modversion['dirname'], $modversion['object_items']);


You then add a class in includes with the filename the same as the table name:

class ModuleNameTable1 extends IcmsPersistableSeoObject { /** * Constructor * * @param object $handler SjbmediaPostHandler object */ public function __construct(& $handler) { global $icmsConfig; $this->IcmsPersistableObject($handler); $this->quickInitVar('title_id', XOBJ_DTYPE_INT, true); $this->quickInitVar('title', XOBJ_DTYPE_TXTBOX, true); $this->quickInitVar('status', XOBJ_DTYPE_INT, false); $this->quickInitVar('date', XOBJ_DTYPE_LTIME, false); $this->initCommonVar('dohtml'); $this->initCommonVar('dobr'); $this->initCommonVar('doimage'); $this->initCommonVar('dosmiley'); $this->initCommonVar('docxode'); $this->IcmsPersistableSeoObject(); }


Is there something else to add? Or have I made a mistake.

I'll be honest in saying I'm nearly on the verge of going back to the old way. A video would be rather helpful or at least some documentation. I'm probably just making this harder in my head than it need be. lol


2010/3/5 19:40:59
#16
Offline
Home away from home

Re: icms_version IPF & SQL - A Little Different?

There is something about this method - installing doesn't always take care of adding/updating the db. After you install, update the module and see what you get.

_________________

Steve Twitter: @skenow Facebook: Steve Kenow


2010/3/5 19:49:36
#17
Offline
Home away from home

Re: icms_version IPF & SQL - A Little Different?

I did try updating once but nothing happened, not sure at what point and which code though as I've played with with it loads since then.

If it doesn't always work, then I'm concerned, perhaps sticking to tried and tested ways is better?

I suppose I should download your module Steve, I keep meaning to try out some wiki's so this would be a good chance to and perhaps also learn from the master


2010/3/6 3:52:13
#18
Offline
Home away from home

Re: icms_version IPF & SQL - A Little Different?

I've never seen that issue Steve. For me, all installations always went fine regarding the creation of database tables.

Tom, did you have a look at any existing fully IPF based module such as banners? There you can see what needs to be done to create those tables required automatically.

Let me know if you need further assistence.

_________________
the german icms website : www.impresscms.de

2010/3/6 8:38:49
#19
Offline
Home away from home

Re: icms_version IPF & SQL - A Little Different?

SimplyWiki is still old school and hasn't been converted to IPF. The new banner module by Phoenyx is fully IPF-based.

@Phoenyx - in early versions of some IPF modules, when you went to the admin of the module for the first time, you would get a message, telling you to update the module and that was when the tables were built. Regardless, updating the module should check the current db tables against the objects and their properties and update the database tables to match, as Marc demonstrates in the videos.

_________________

Steve Twitter: @skenow Facebook: Steve Kenow


2010/3/6 10:17:48
#20
Offline
Home away from home

Re: icms_version IPF & SQL - A Little Different?

Quote:

Tom, did you have a look at any existing fully IPF based module such as banners? There you can see what needs to be done to create those tables required automatically.



Yeah I looked at content (I think this came from imBuilding?), I'll download the banner module and look there also.

I then used imBuilding to make a basic module so that I had something for comparison.

Thanks guys, oh and Phoenyx I'm sure I'll start pestering you soon when I get stuck


Reply New Topic extras
 Previous Topic   Next Topic
You can view topic.
You can start a new topic.
You can reply to posts.
You cannot edit your posts.
You cannot delete your posts.
You cannot add new polls.
You cannot vote in polls.
You cannot attach files to posts.
You can post without approval.