Main Page | Modules | File List | File Members

Link storage and retrieval


Functions

 links_get_link_where_sql ($link_spec, $tablename="{links}")
 links_get_link ($link_spec)
 links_put_link ($url, $title='')

Function Documentation

links_get_link link_spec  ) 
 

Given a URL, URL hash, or link ID (lid), retrieves any existing link record from the database as an array.

links_get_link_where_sql link_spec,
tablename = "{links}"
 

This internal function creates an SQL WHERE clause to select a record from the {links} table based on an integer link ID or a URL (which is normalized and hashed before the query). The returned SQL will be a WHERE clause with leading and trailing blanks for convenient concatenation. Note that no query is executed here.

Accepts an MD5 string for the $link_spec, to match directly against the url_md5 field in the database. The assumption is that a raw hex number exactly 32 characters in length won't be a URL. The hex characters A-F are matched case-insensitively.

The $tablename optional parameter defaults to {links} but can specify a table alias if this WHERE is to be used in a join query. Remember to use the curly-brackets for actual table names, but not for alias names, so that database prefixes will work right.

links_put_link url,
title = ''
 

This low-level function simply adds a bare URL record, with no associated node, to the database. It returns the new link ID number if successful, or 0 if it fails.

The function checks for an existing matching link before adding a new record, and if one is found, that links ID is returned instead of a new one being assigned.

The optional title field is only used if a new link is being inserted.


Generated on Tue Aug 1 10:19:37 2006 for Drupal Links Package by  doxygen 1.4.4