本文整理汇总了PHP中ca_lists::getDb方法的典型用法代码示例。如果您正苦于以下问题:PHP ca_lists::getDb方法的具体用法?PHP ca_lists::getDb怎么用?PHP ca_lists::getDb使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ca_lists
的用法示例。
在下文中一共展示了ca_lists::getDb方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getListAsHTMLFormElement
//.........这里部分代码省略.........
if (!isset($pa_options['omitItemsWithID']) || !is_array($pa_options['omitItemsWithID']) || !sizeof($pa_options['omitItemsWithID'])) {
$pa_options['omitItemsWithID'] = null;
}
if (isset($pa_options['nullOption']) && $pa_options['nullOption'] && $vs_render_as != 'checklist') {
$va_options[''] = $pa_options['nullOption'];
}
if (is_array($pa_options['limitToItemsWithID']) && sizeof($pa_options['limitToItemsWithID'])) {
// expand limit list to include parents of items that are included
$va_to_add = array();
foreach ($va_list_items as $vn_item_id => $va_item) {
if (($vn_parent_id = $va_item['parent_id']) && in_array($vn_item_id, $pa_options['limitToItemsWithID'])) {
$va_to_add[$vn_parent_id] = true;
while ($vn_parent_id = $va_list_items[$vn_parent_id]['parent_id']) {
if ($va_list_items[$vn_parent_id]['parent_id']) {
$va_to_add[$va_list_items[$vn_parent_id]['parent_id']] = true;
}
}
}
}
$pa_options['limitToItemsWithID'] += array_keys($va_to_add);
}
$pa_check_access = caGetOption('checkAccess', $pa_options, null);
if (!is_array($pa_check_access) && $pa_check_access) {
$va_check_access = array($va_check_access);
}
$va_in_use_list = null;
if ($pa_options['inUse'] && (int) $pa_options['element_id'] && $pa_options['table']) {
$o_dm = Datamodel::load();
if ($t_instance = $o_dm->getInstance($pa_options['table'], true)) {
$va_params = array((int) $pa_options['element_id']);
if (is_array($pa_check_access) && sizeof($pa_check_access)) {
$va_params[] = $pa_check_access;
}
$qr_in_use = $t_list->getDb()->query("\n\t\t\t\t\tSELECT DISTINCT cav.item_id\n\t\t\t\t\tFROM ca_attribute_values cav\n\t\t\t\t\tINNER JOIN ca_attributes AS ca ON ca.attribute_id = cav.attribute_id\n\t\t\t\t\tINNER JOIN " . $t_instance->tableName() . " AS t ON t." . $t_instance->primaryKey() . " = ca.row_id\n\t\t\t\t\tWHERE \n\t\t\t\t\t\t(cav.element_id = ?) AND \n\t\t\t\t\t\t(ca.table_num = " . $t_instance->tableNum() . ") \n\t\t\t\t\t\t" . ($t_instance->hasField('deleted') ? " AND (t.deleted = 0)" : "") . "\n\t\t\t\t\t\t" . (is_array($pa_check_access) && sizeof($pa_check_access) ? " AND t.access IN (?)" : "") . "\n\t\t\t\t", $va_params);
$va_in_use_list = $qr_in_use->getAllFieldValues('item_id');
}
}
$va_colors = array();
$vn_default_val = null;
foreach ($va_list_items as $vn_item_id => $va_item) {
if (is_array($pa_options['limitToItemsWithID']) && !in_array($vn_item_id, $pa_options['limitToItemsWithID'])) {
continue;
}
if (is_array($pa_options['omitItemsWithID']) && in_array($vn_item_id, $pa_options['omitItemsWithID'])) {
continue;
}
if (is_array($va_in_use_list) && !in_array($vn_item_id, $va_in_use_list)) {
continue;
}
$va_options[$va_item[$pa_options['key']]] = str_repeat(' ', intval($va_item['LEVEL']) * 3) . ' ' . $va_item['name_singular'];
if (!$va_item['is_enabled'] || is_array($va_disabled_item_ids) && in_array($vn_item_id, $va_disabled_item_ids)) {
$va_disabled_options[$va_item[$pa_options['key']]] = true;
}
$va_colors[$vn_item_id] = $va_item['color'];
if ($va_item['is_default']) {
$vn_default_val = $va_item[$pa_options['key']];
}
// get default value
if ($va_item['is_default'] && (!isset($pa_options['nullOption']) || isset($pa_options['useDefaultWhenNull']) && (bool) $pa_options['useDefaultWhenNull'])) {
// set default if needed, but only if there's not a null option set
if (!is_array($pa_options['value']) && (!isset($pa_options['value']) || !strlen($pa_options['value']))) {
$pa_options['value'] = $vn_default_val;
} else {
if (is_array($pa_options['value']) && !sizeof($pa_options['value'])) {
$pa_options['value'] = array(0 => $vn_default_val);
}