function get_site_url_id($site_url_address) { global $memcacheWorking, $memcache; $site_domain_id = INDEXES::get_site_domain_id($site_url_address); if ($memcacheWorking) { $time = 604800; //7 days in sec //get from memcached $getURL = $memcache->get(md5("url-id" . $site_url_address . systemHash())); if ($getURL) { return $getURL; } else { $database = DB::getInstance(); $db = $database->getConnection(); $mysql['site_url_address'] = $db->real_escape_string($site_url_address); $mysql['site_domain_id'] = $db->real_escape_string($site_domain_id); $site_url_sql = "SELECT site_url_id FROM 202_site_urls WHERE site_url_address='" . $mysql['site_url_address'] . "' limit 1"; $site_url_result = _mysqli_query($site_url_sql); $site_url_row = $site_url_result->fetch_assoc(); if ($site_url_row) { //if this site_url_id already exists, return the site_url_id for it. $site_url_id = $site_url_row['site_url_id']; $setID = $memcache->set(md5("url-id" . $site_url_address . systemHash()), $site_url_id, false, $time); return $site_url_id; } else { $site_url_sql = "INSERT INTO 202_site_urls SET site_domain_id='" . $mysql['site_domain_id'] . "', site_url_address='" . $mysql['site_url_address'] . "'"; $site_url_result = _mysqli_query($site_url_sql); //($site_url_sql); $site_url_id = $db->insert_id; $setID = $memcache->set(md5("url-id" . $site_url_address . systemHash()), $site_url_id, false, $time); return $site_url_id; } } } else { $database = DB::getInstance(); $db = $database->getConnection(); $mysql['site_url_address'] = $db->real_escape_string($site_url_address); $mysql['site_domain_id'] = $db->real_escape_string($site_domain_id); $site_url_sql = "SELECT site_url_id FROM 202_site_urls WHERE site_url_address='" . $mysql['site_url_address'] . "' limit 1"; $site_url_result = _mysqli_query($site_url_sql); $site_url_row = $site_url_result->fetch_assoc(); if ($site_url_row) { //if this site_url_id already exists, return the site_url_id for it. $site_url_id = $site_url_row['site_url_id']; return $site_url_id; } else { $site_url_sql = "INSERT INTO 202_site_urls SET site_domain_id='" . $mysql['site_domain_id'] . "', site_url_address='" . $mysql['site_url_address'] . "'"; $site_url_result = _mysqli_query($site_url_sql); //($site_url_sql); $site_url_id = $db->insert_id; return $site_url_id; } } }
function get_site_url_id($site_url_address) { $mysql['site_url_address'] = mysql_real_escape_string($site_url_address); $site_url_sql = "SELECT site_url_id FROM 202_site_urls WHERE site_url_address='" . $mysql['site_url_address'] . "'"; $site_url_result = _mysql_query($site_url_sql); $site_url_row = mysql_fetch_assoc($site_url_result); if ($site_url_row) { //if this site_url_address already exists, return the site_url_id for it. $site_url_id = $site_url_row['site_url_id']; return $site_url_id; } else { //else if this doesn't exist, insert the new iprow, and return the_id for this new row we found //but before we do this, we need to grab the site_domain_id $site_domain_id = INDEXES::get_site_domain_id($site_url_address); $mysql['site_domain_id'] = mysql_real_escape_string($site_domain_id); $site_url_sql = "INSERT INTO 202_site_urls SET site_domain_id='" . $mysql['site_domain_id'] . "', site_url_address='" . $mysql['site_url_address'] . "'"; $site_url_result = _mysql_query($site_url_sql); //($site_url_sql); $site_url_id = mysql_insert_id(); return $site_url_id; } }