eZPersistentObject - foreign_class

Author Message

Thiago Campos Viana

Wednesday 09 February 2011 6:15:22 am

Hello

I'm just wondering what this attribute does. I opened the ezcontentclass.php file and there's a block:

'initial_language_id' => array( 'name' => "InitialLanguageID",
'datatype' => 'integer',
'default' => 0,
'required' => true,
'foreign_class' => 'eZContentLanguage',
'foreign_attribute' => 'id',
'multiplicity' => '1..*' ),

Then I opened kernel_schema.sql and there's no foreign key specification there, so I supposed that the control of foreign key attribute values is done by eZPersistentObject class and not by the database.

So I created two database tables, without specifying foreign keys attributes, and two classes that extends eZPersistentObject, just to test if the code would give me an error when I tried to store a object that has a value wich I specified defining 'foreign_class' attribute, and code just works, it stores a new table row even if the referenced eZPersistentObject class has no objects with the key I specified for the new object.

So what 'foreign_class' does?

eZ Publish Certified Developer: http://auth.ez.no/certification/verify/376924

Twitter: http://twitter.com/tcv_br

Gaetano Giunta

Wednesday 09 February 2011 12:47:15 pm

So that in the future we can take advantage of it ;-)

Principal Consultant International Business
Member of the Community Project Board

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 30 2025 00:13:20
Script start
Timing: Jan 30 2025 00:13:20
Module start 'layout'
Timing: Jan 30 2025 00:13:20
Module start 'content'
Timing: Jan 30 2025 00:13:20
Module end 'content'
Timing: Jan 30 2025 00:13:20
Script end

Main resources:

Total runtime0.0149 sec
Peak memory usage2,048.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0057 588.1406151.2109
Module start 'layout' 0.00570.0022 739.351636.6563
Module start 'content' 0.00780.0057 776.007890.2031
Module end 'content' 0.01360.0013 866.210929.9766
Script end 0.0148  896.1875 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002517.0717140.0002
Check MTime0.00138.9294140.0001
Mysql Total
Database connection0.00085.622210.0008
Mysqli_queries0.002516.654930.0008
Looping result0.00000.067310.0000
Template Total0.00106.710.0010
Template load0.00085.527610.0008
Template processing0.00021.176710.0002
Override
Cache load0.00053.658310.0005
General
dbfile0.002114.415380.0003
String conversion0.00000.041740.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs