xo::db::Class proc get_instance_from_db (public)

 xo::db::Class[i] get_instance_from_db [ -id id ]

Defined in packages/xotcl-core/tcl/05-db-procs.tcl

Create an XOTcl object from an acs_object_id. This method determines the type and initializes the object from the information stored in the database. The XOTcl object is destroyed automatically on cleanup (end of a connection request).

Switches:
-id
(optional)
Returns:
fully qualified object

Partial Call Graph (max 5 caller/called nodes):
%3 test_test_xo_db_object test_xo_db_object (test xotcl-core) xo::db::Class proc get_instance_from_db xo::db::Class proc get_instance_from_db test_test_xo_db_object->xo::db::Class proc get_instance_from_db test_xotcl_core_tutorial_1 xotcl_core_tutorial_1 (test xotcl-core) test_xotcl_core_tutorial_1->xo::db::Class proc get_instance_from_db test_xotcl_core_tutorial_2 xotcl_core_tutorial_2 (test xotcl-core) test_xotcl_core_tutorial_2->xo::db::Class proc get_instance_from_db db_1row db_1row (public) xo::db::Class proc get_instance_from_db->db_1row

Testcases:
xotcl_core_tutorial_1, xotcl_core_tutorial_2, test_xo_db_object
Source code:
set type  [:get_object_type -id $id]
set class [::xo::db::Class object_type_to_class $type]
if {![:isclass $class]} {
  error "no class $class defined"
}
set r [$class create ::$id]
$r db_1row dbqd..get_instance [$class fetch_query $id]
$r set object_id $id
$r destroy_on_cleanup
$r initialize_loaded_object
return $r
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: