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

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 18 2025 19:30:37
Script start
Timing: Jan 18 2025 19:30:37
Module start 'layout'
Timing: Jan 18 2025 19:30:37
Module start 'content'
Timing: Jan 18 2025 19:30:38
Module end 'content'
Timing: Jan 18 2025 19:30:38
Script end

Main resources:

Total runtime0.8730 sec
Peak memory usage4,096.0000 KB
Database Queries74

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0065 588.0469152.6406
Module start 'layout' 0.00650.0035 740.687539.4922
Module start 'content' 0.01000.8613 780.1797581.4609
Module end 'content' 0.87130.0017 1,361.640616.1250
Script end 0.8730  1,377.7656 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00340.3871160.0002
Check MTime0.00130.1486160.0001
Mysql Total
Database connection0.00070.081910.0007
Mysqli_queries0.805792.2924740.0109
Looping result0.00070.0811720.0000
Template Total0.837395.920.4187
Template load0.00220.246420.0011
Template processing0.835295.667120.4176
Template load and register function0.00020.022210.0002
states
state_id_array0.00100.109710.0010
state_identifier_array0.00090.099620.0004
Override
Cache load0.00190.2184790.0000
Sytem overhead
Fetch class attribute can translate value0.00060.064430.0002
Fetch class attribute name0.00190.222780.0002
XML
Image XML parsing0.00030.035730.0001
class_abstraction
Instantiating content class attribute0.00000.002080.0000
General
dbfile0.00070.0841100.0001
String conversion0.00000.000940.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
8content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
24content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
17content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 51
 Number of unique templates used: 5

Time used to render debug report: 0.0001 secs