3 include_once($path_to_root . "/includes/db/references_db.inc");
8 function save($type, $id, $reference)
10 add_reference($type, $id, $reference);
12 references::save_last($reference, $type);
15 function get($type, $id)
17 return get_reference($type, $id);
20 function delete($type, $id)
22 delete_reference($type, $id);
25 function exists($type, $reference)
27 return (find_reference($type, $reference) != null);
30 function save_last($reference, $type)
32 $next = references::increment($reference);
33 save_next_reference($type, $next);
36 function get_next($type)
38 return get_next_reference($type);
41 //------------------------------------
43 function is_valid($reference)
45 return strlen(trim($reference)) > 0;
48 function increment($reference)
50 if (is_numeric($reference))
51 return $reference + 1;
56 //------------------------------------
59 //----------------------------------------------------------------------------
61 function is_new_reference($ref, $type)
63 $db_info = get_systype_db_info($type);
64 $db_name = $db_info[0];
65 $db_type = $db_info[1];
66 $db_ref = $db_info[3];
70 $sql = "SELECT $db_ref FROM $db_name WHERE $db_ref='$ref'";
72 $sql .= " AND $db_type=$type";
74 $result = db_query($sql, "could not test for unique reference");
76 return (db_num_rows($result) == 0);
79 // it's a type that doesn't use references - shouldn't be calling here, but say yes anyways