= implode(" AND ", $_where); } $sql = "select COUNT(*) FROM ".LINK_EXCHANGE_LINKS_TABLE." WHERE ".$_where; $result = db_query($sql); list($links_number) = db_fetch_row($result); return $links_number; } /** * add new link to category and return new link id * * @return integer */ function le_addLink($_link){ $sql = "select le_lID FROM ".LINK_EXCHANGE_LINKS_TABLE." WHERE le_lURL='".$_link['le_lURL']."'"; list($_le_lID) = db_fetch_row(db_query($sql)); if(!empty($_le_lID))return false; $sql = "INSERT INTO ".LINK_EXCHANGE_LINKS_TABLE." (".implode(", ", (array_keys($_link))).") VALUES('".implode("', '", $_link)."')"; db_query($sql); return db_insert_id(); } /** * update link * * @param array of new values * @return bool */ function le_SaveLink($_link){ if(key_exists('le_lURL', $_link)){ $sql = "select le_lID FROM ".LINK_EXCHANGE_LINKS_TABLE." WHERE le_lURL='".$_link['le_lURL']."' AND le_lID!=".(int)$_link['le_lID']; list($_le_lID) = db_fetch_row(db_query($sql)); if($_le_lID) return false; $_le_lID = $_link['le_lID']; } else $_le_lID = $_link['le_lID']; foreach($_link as $_col => $_val){ if($_val == 'NULL' && $_col=='le_lVerified'){ $_link[$_col] = $_col." = NULL"; }else{ $_link[$_col] = $_col." = '".$_val."'"; } } $sql = "UPDATE ".LINK_EXCHANGE_LINKS_TABLE." SET ".implode(", ", $_link)." WHERE le_lID=".(int)$_le_lID; db_query($sql); return true; } function le_DeleteLink($_le_lID){ $sql = "DELETE FROM ".LINK_EXCHANGE_LINKS_TABLE." WHERE le_lID=".(int)$_le_lID; db_query($sql); } ?>