Forums / Developer / Modules: Howto insert data to database... Help needed.

Modules: Howto insert data to database... Help needed.

Author Message

Jerry Jalava

Sunday 27 July 2003 11:45:58 am

Hi,

I've been building modules and now there are almoust ready... Important feature that I'm missing is saving data to database.

Some hints how to do this would be extremely helpfull...

Here's what I'm doing right now:

I have a file witch keeps inside all the functions that happens inside my module...
File: Adds.php:
-----------
include_once( 'kernel/classes/ezpersistentobject.php' );

class Adds extends eZPersistentObject
{
var $AddsID=NULL;

function Adds( $row )
{
$this->eZPersistentObject( $row );
}

function &definition()
{
(Definitions here...)
}

function &createAdds( $AddsID, $currentUserID, $data1, $data2...etc )
{
$Added = Adds::currentDay();
$Expires = Adds::createExpTime($OldRule);

$row = array(
'id' => $AddsID,
'user_id' => $currentUserID,
'Added' => $Added,
'Expires' => $Expires,
'Data1' => $data1,
'data2' => $data2,
etc.... );

return new Adds( $row );
}

...Some more functions...

---------------

What should I do now, to get the data _saved_ in the _database_?
Should I execute somewhere this eZPersistentObject's function "store"?
And if should, where?

Right now it stops in the function "fill"... Right?

You can get the Idea how the rest of the module is done, by looking that tutorial that I sended before...

Someone from eZ crew, please help...
I think this is easy and fast to answer.

Thanks,
Jerry

Jerry Jalava

Monday 28 July 2003 1:10:40 am

PLS. Someone...

Regards,
Jerry

Selmah Maxim

Monday 28 July 2003 3:05:16 am

You need to use Ezdb and make query from db !

Jerry Jalava

Monday 28 July 2003 5:45:31 am

Hi Selmah,

That doesn't do the trick in this problem... I already can fetch the data from database, but I don't know what kind of parameters shoul I send to eZPersistentObject.php so it would _save_ the data to database... Like you see from above example I already know how to send data to PersistentObject, but don't know how can I send it the "save to database" command...

Seems like I have to spend lot more time with schooling eZ, 'cause I never had an answer to these kind of question from the people that really know the system aka ez staff...
No hard feelings, it's just wierd that these kind of simple things cannot be answered...

Regards,
Jerry

Selmah Maxim

Monday 28 July 2003 6:06:32 am

I see ..

This may help you,if look the /kernel/classes/ezpersistentobject.php , you file function 'storeObject' with ($obj, $fieldFilters) parameters !

Also you can take a look at another files to see how its work, coz I think this the function to store to the DB !

Jerry Jalava

Monday 28 July 2003 11:55:06 am

Finally got it working...
I just lost one day again because of this problem...

Soon gonna add it to the tutorial in the documentation, after I have finished this module first... I have no time at this moment...

Regards,
Jerry

Francisco Felix

Tuesday 29 July 2003 2:07:35 pm

I hope you can get time soon, I have not found good documentation about writing your own modules, any help on this matter would be really appreciated.

Jerry Jalava

Wednesday 30 July 2003 2:11:47 am

Hi,

If you want to practise building modules, you should check my first tutorial... http://www.ez.no/developer/ez_publish_3/documentation/development/extensions/module/module_tutorial_part_1

Hope it's any help...
I'm trying to write the second part on weekend...

Regards,
Jerry