Skip to content

Instantly share code, notes, and snippets.

@cam8001
Created January 29, 2012 18:45
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cam8001/1700086 to your computer and use it in GitHub Desktop.
Save cam8001/1700086 to your computer and use it in GitHub Desktop.
Building a drupal query
$arg = "%".drupal_get_path_alias($_GET['q'])."%";
echo $arg;
$query = db_select('url_alias', 't');
$query->fields('t');
$query->condition('t.alias', '$arg', 'LIKE');
$query->range(0, 1);
$result = $query->execute();
while ($record = $result->fetchAssoc()) {
print_r($record);
}
@taz77
Copy link

taz77 commented Jan 29, 2012

$arg = drupal_get_path_alias($_GET['q']);
$arg = db_like($arg) . '%';
$query = db_select('url_alias', 't');
$query->fields('t')
->condition('t.alias', '$arg', 'LIKE')
->range(0, 1);
$result = $query->execute();
$result->fetchAll();
print_r($result);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment