| 407 | 1 package IMPL::ORM; | 
|  | 2 use strict; | 
|  | 3 use warnings; | 
|  | 4 | 
|  | 5 use parent qw(IMPL::Object); | 
|  | 6 use IMPL::Class::Property; | 
|  | 7 use Scalar::Util qw(weaken refaddr); | 
|  | 8 | 
|  | 9 use IMPL::Exception; | 
|  | 10 | 
|  | 11 our $Depth = 1; # загружать объект + 1 уровень детей | 
|  | 12 our $UseProxy = 1; | 
|  | 13 | 
|  | 14 BEGIN { | 
|  | 15     private property _ObjectCache => prop_all; | 
|  | 16     private property _MapInstances => prop_all; | 
|  | 17     private property _WorkUnit => prop_all; | 
|  | 18     public property Schema => prop_all; | 
|  | 19 } | 
|  | 20 | 
|  | 21 sub ObjectInfoById { | 
|  | 22     my ($this,$oid) = @_; | 
|  | 23 | 
|  | 24     return $this->_ObjectCache->{$oid}; | 
|  | 25 } | 
|  | 26 | 
|  | 27 sub ObjectInfo { | 
|  | 28     my ($this,$inst) = @_; | 
|  | 29 | 
|  | 30     die new IMPL::InvalidOperationException("This method can be used only for a reference") unless ref $inst; | 
|  | 31 | 
|  | 32     return $this->_MapInstances->{refaddr $inst}; | 
|  | 33 } | 
|  | 34 | 
|  | 35 | 
|  | 36 1; | 
|  | 37 __END__ | 
|  | 38 | 
|  | 39 =pod | 
|  | 40 | 
|  | 41 =head1 NAME | 
|  | 42 | 
|  | 43 C<IMPL::ORM> - Object Relational Mapping | 
|  | 44 | 
|  | 45 =head1 SYNOPSIS | 
|  | 46 | 
|  | 47 =begin code | 
|  | 48 | 
|  | 49 my $ds = IMPL::ORM::Storage::DBIC->new('My::Data',$dsn,$user,$pass,{Autocommit => 1}); | 
|  | 50 | 
|  | 51 | 
|  | 52 my $foo = $ds->Insert( | 
|  | 53     My::Data::Foo->new( | 
|  | 54         'foo class' | 
|  | 55     ) | 
|  | 56 ); | 
|  | 57 | 
|  | 58 my $bar = $ds->Insert( | 
|  | 59     My::Data::Bar->new( | 
|  | 60         'bar class' | 
|  | 61     ) | 
|  | 62 ) | 
|  | 63 | 
|  | 64 $bar->fooObject($foo); | 
|  | 65 | 
|  | 66 $ds->Save($bar); | 
|  | 67 | 
|  | 68 my $fooOther = $ds->Retrieve( | 
|  | 69     'My::Data::Bar', | 
|  | 70     { | 
|  | 71         name =>  'bar class', | 
|  | 72         fooObject => { | 
|  | 73             name => 'some foo' | 
|  | 74         } | 
|  | 75     } | 
|  | 76 ) | 
|  | 77 | 
|  | 78 =end code | 
|  | 79 | 
|  | 80 =head1 DESCRIPTION | 
|  | 81 | 
|  | 82 =cut |