xo::db::CrClass proc lookup (public)

 xo::db::CrClass[i] lookup -name name  [ -parent_id parent_id ] \
    [ -content_type content_type ]

Defined in /var/www/openacs.org/packages/xotcl-core/tcl/cr-procs.tcl

Check, whether a content item with the given name exists. When content_type is provided (e.g. -content_type "::%") then a like operation is applied on the value.

Switches:
-name (required)
-parent_id (optional, defaults to "-100")
-content_type (optional)
Returns:
item_id If the item exists, return its item_id, otherwise 0.

Testcases:
xotcl_core_tutorial_4, create_folder_with_page, xowiki_test_cases, path_resolve
Source code:
if {[info exists content_type]} {
  set result [::xo::dc get_value lookup_by_name_and_ct {
    select item_id from cr_items
    where name = :name and parent_id = :parent_id
    and content_type like :content_type
  } 0]
} else {
  set result [::xo::dc get_value lookup_by_name {
    select item_id from cr_items
    where name = :name and parent_id = :parent_id
  } 0]
}
return $result
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: