/** * Used to retrieve user pattern from the database * @param int $userpattern_id * @access public * @return UserPattern **/ public static function get($userpattern_id) { global $cdg_sql, $err; $obm_q = new DB_OBM(); $db_type = $obm_q->type; $timecreate = sql_date_format($db_type, "timecreate", "timecreate"); $timeupdate = sql_date_format($db_type, "timeupdate", "timeupdate"); // WHERE construction $where = array(); $id = sql_parse_id($userpattern_id, true); $where[] = "id {$id}"; //multidomain if (!$GLOBALS['obm']['domain_global']) { $domain_id = sql_parse_id($GLOBALS['obm']['domain_id'], true); $where[] = "(domain_id {$domain_id})"; } if (!empty($where)) { $whereq = 'WHERE ' . implode(' AND ', $where); } // Querying $query = "SELECT\n id,\n domain_id,\n {$timecreate},\n {$timeupdate},\n title,\n description\n FROM userpattern\n {$whereq}"; display_debug_msg($query, $cdg_sql, "UserPattern::get()"); $obm_q->query($query); if (!$obm_q->next_record()) { $err['msg'] = $GLOBALS['l_id_error']; return false; } //else $pattern = new UserPattern($obm_q->f('title'), $obm_q->f('description')); $pattern->id = $obm_q->f('id'); $pattern->domain_id = $obm_q->f('domain_id'); $pattern->loadAttributes(); return $pattern; }