Execute($query); if (!$result->RecordCount()) { $country_id = 0; } else { $country_id = $result->fields['countries_id']; } return $country_id; } /** * Return the country_iso_code_2 based on the country's id * * @param $country_id integer * @return string */ function oos_get_country_isocode2($country_id) { // Get database information $dbconn =& oosDBGetConn(); $oostable =& oosDBGetTables(); $query = "SELECT countries_iso_code_2 FROM " . $oostable['countries'] . " WHERE countries_id = '" . intval($country_id) . "'"; $result = $dbconn->Execute($query); if (!$result->RecordCount()) { $country_iso = 0; } else { $country_iso = $result->fields['countries_iso_code_2']; } return $country_iso; } /** * Return the zone_id based on the zone's name * * @param $country_id integer * @param $zone_name string * @return integer */ function oos_get_zone_id($country_id, $zone_name) { // Get database information $dbconn =& oosDBGetConn(); $oostable =& oosDBGetTables(); $query = "SELECT zone_id FROM " . $oostable['zones'] . " WHERE zone_country_id = '" . intval($country_id) . "' AND zone_name = '" . oos_db_input($zone_name) . "'"; $result = $dbconn->Execute($query); if (!$result->RecordCount()) { $zone_id = 0; } else { $zone_id = $result->fields['zone_id']; } return $zone_id; } /** * Return result of check the existence of a database field * * @param $table string * @param $field string * @return boolean */ function oos_field_exists($table, $field) { // Get database information $dbconn =& oosDBGetConn(); $describe_result = $dbconn->Execute("describe $table"); while($d_row = $describe_result->fields) { if ($d_row["Field"] == "$field") return TRUE; // Move that ADOdb pointer! $describe_result->MoveNext(); } return FALSE; } /** * Return string with changed quotes to HTML equivalents for form inputs. * * @param $string string * @return string */ function oos_html_quotes($string) { return str_replace("'", "'", $string); } /** * Return string with changed HTML equivalents back to quotes * * @param $string string * @return string */ function oos_html_unquote($string) { return str_replace("'", "'", $string); }