function getFieldsByLookup($table, $subtable, $f_id) { $cats = FormDB::getCatSelection($table, $subtable, $f_id); foreach ($cats as $c_id) { $result = db_query_array("SELECT id, name FROM {$subtable} WHERE id = {$c_id}"); $results[] = $result[0]; } return $results; }
function setOrder($id, $order_by, $order_asc, $control_id, $user_id) { if (empty($order_by) || !($control_id > 0) || !($user_id > 0)) { return false; } if ($id > 0) { return FormDB::update('admin_order', array('order_by' => $order_by, 'order_asc' => $order_asc), $id); } else { return FormDB::insert('admin_order', array('control_id' => $control_id, 'user_id' => $user_id, 'order_by' => $order_by, 'order_asc' => $order_asc)); } }
function serializeCommas($value, $serialize = false) { if (stristr($value, ',')) { preg_match_all('#\\((.*?)\\)#', $value, $m); $parenthesis = $m[1]; $value = preg_replace('#\\((.*?)\\)#', '$$$', $value); $k = 0; $array = explode(',', $value); if (is_array($array)) { foreach ($array as $v) { if (stristr($v, '=>')) { $array1 = explode('=>', $v); if (!stristr($array1[1], '$$$')) { $i = $array1[0]; $new_array[$i] = $array1[1]; } else { $i = $array1[0]; $new_array[$i] = FormDB::serializeCommas($parenthesis[$k]); $k++; } } else { if (stristr($v, '=>')) { $array = explode('=>', $v1); $i = $array[0]; $new_array[$i] = $array[1]; } else { $new_array[] = $v; } } } } } else { $new_array[] = $value; } if ($serialize) { $fields_array = serialize($new_array); } else { $fields_array = $new_array; } return $fields_array; }