I'm very much a beginner at Drupal development, MySQL, and pretty much everything, so this may seem trivial, but I would really appreciate any help I can get here. I'm getting this error, and I'm not really sure what's wrong, because everything was working fine before, and I didn't change anything around the area that it mentions since the last time it was working perfectly.
The exact error is:
PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ASC' at line 3: SELECT n.nid AS nid FROM {node} n INNER JOIN {embryo_log} a ON n.nid = a.nid WHERE (n.type = :db_condition_placeholder_0) AND (a.expiration_date > :db_condition_placeholder_1_0) ORDER BY n.sticky DESC, n.changed DESC ASC; Array ( [:db_condition_placeholder_0] => embryo_log [:db_condition_placeholder_1_0] => -1 ) in embryo_log_all() (line 599 of /data/www/drupal-7.34/sites/all/modules/embryo_log/embryo_log.module)."
Here is the entire function that the error is referencing, because I don't know what might be relevant:
function embryo_log_all($option = NULL, $action = NULL) {
$nodes_per_page = variable_get('embryo_log_per_page', variable_get('default_nodes_main', 10));
$output = '<div class="embryo_log">';
// If the optional param is numeric, assume it is a node or term id.
if (is_numeric($option)) {
if ($action == 'group') {
// Get all embryo_log with this term.
// TODO Change fully to a dynamic query
$result = db_query("SELECT n.nid FROM {node} n LEFT JOIN {taxonomy_index} tn USING (nid) WHERE n.type = :n.type AND n.status = :n.status AND tn.tid = :tn.tid", array(':n.type' => 'embryo_log', ':n.status' => 1, ':tn.tid' => $option));
foreach ($result as $nid) {
$embryo_log = node_load($nid->nid);
$output .= '<h2>' . check_plain($embryo_log->title) . '</h2>';
$build = node_view($embryo_log);
$output .= drupal_render($build);
}
return $output . '</div>';
}
else {
$embryo_log = node_load($option);
// If it is an embryo_log, ok, else ignore it.
if ($embryo_log != NULL) {
if ($embryo_log->type == 'embryo_log') {
$build = node_view($embryo_log, 'full');
// Plain node title
$outp = '<h2>' . check_plain($embryo_log->title) . '</h2>';
$build['#node']->title = ''; // Don't render title
return $outp . drupal_render($build);
}
}
}
}
if (user_access('edit embryo_log')) {
$args = array(-1);
}
else {
$args = array(gmdate("U"));
}
// $query = "SELECT n.nid FROM {node} n INNER JOIN {embryo_log} a ON n.nid=a.nid
// WHERE n.type='embryo_log' AND a.expiration_date > %d
// ORDER BY " . variable_get('embryo_log_page_order', 'n.sticky DESC, n.changed DESC');
$query = db_select('node', 'n');
$query->extend('PagerDefault')
->limit($nodes_per_page);
$query->innerJoin('embryo_log', 'a', 'n.nid = a.nid');
$query->condition('n.type', 'embryo_log', '=')
->condition('a.expiration_date', $args, '>')
->fields('n', array('nid'))
->orderBy(variable_get('embryo_log_page_order', 'n.sticky, n.changed'), '');
// $query_result = pager_query(db_rewrite_sql($query, 'n', 'nid'), $nodes_per_page, 0, NULL, $args);
$query_result = $query->execute();
foreach ($query_result as $nid) {
$embryo_log = node_load($nid->nid);
$build = node_view($embryo_log, $option);
$output .= drupal_render($build);
}
$output .= '</div>';
$output .= theme('pager', array('tags' => NULL));
return $output;
}
And the line in there that is specifically being referenced in the error (line 599) is the one towards the bottom that says $query_result = $query->execute();
Any help would be greatly appreciated, because everything looks fine to me, and I'm at a loss.
Thanks!