49
|
1 package IMPL::ORM;
|
|
2 use strict;
|
|
3 use warnings;
|
|
4
|
166
|
5 use parent qw(IMPL::Object);
|
49
|
6 use IMPL::Class::Property;
|
|
7 use Scalar::Util qw(weaken refaddr);
|
|
8
|
|
9 use IMPL::Exception;
|
|
10
|
180
|
11 our $Depth = 1; # загружать объект + 1 уровень детей
|
49
|
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__
|
79
|
38
|
49
|
39 =pod
|
79
|
40
|
|
41 =head1 NAME
|
|
42
|
|
43 C<IMPL::ORM> - Object Relational Mapping
|
|
44
|
49
|
45 =head1 SYNOPSIS
|
|
46
|
79
|
47 =begin code
|
49
|
48
|
79
|
49 my $ds = IMPL::ORM::Storage::DBIC->new('My::Data',$dsn,$user,$pass,{Autocommit => 1});
|
|
50
|
49
|
51
|
79
|
52 my $foo = $ds->Insert(
|
194
|
53 My::Data::Foo->new(
|
|
54 'foo class'
|
|
55 )
|
79
|
56 );
|
49
|
57
|
79
|
58 my $bar = $ds->Insert(
|
194
|
59 My::Data::Bar->new(
|
|
60 'bar class'
|
|
61 )
|
79
|
62 )
|
|
63
|
|
64 $bar->fooObject($foo);
|
|
65
|
|
66 $ds->Save($bar);
|
49
|
67
|
79
|
68 my $fooOther = $ds->Retrieve(
|
194
|
69 'My::Data::Bar',
|
|
70 {
|
|
71 name => 'bar class',
|
|
72 fooObject => {
|
|
73 name => 'some foo'
|
|
74 }
|
|
75 }
|
79
|
76 )
|
49
|
77
|
79
|
78 =end code
|
49
|
79
|
|
80 =head1 DESCRIPTION
|
|
81
|
180
|
82 =cut
|