sql query not working in drupal when fetching more than 100 rows
I was trying to execute this mysql query it is not giving me any results if i set the query_limit to more than 100, can somebody point me what i can do to get this working开发者_如何学Go for fetching more data.
$query_limit = 190;
$query1 = "SELECT N.nid ,N.tid FROM term_node N JOIN term_data S ON S.tid = N.tid AND S.vid =1";
$query_result = db_query_range($query1, $vid, 0, $query_limit);
Given your example, you do not pass the right parameters to db_query_range
. You should either try without passing the unused query parameter substitution $vid
:
$query_limit = 190;
$query1 = "SELECT N.nid ,N.tid FROM term_node N JOIN term_data S ON S.tid = N.tid AND S.vid = 1";
$query_result = db_query_range($query1, 0, $query_limit);
or better, use it properly by referencing it in your query (the %d
at the end of your query will get substituted by the value of $vid
:
$vid = 1;
$query_limit = 190;
$query1 = "SELECT N.nid ,N.tid FROM term_node N JOIN term_data S ON S.tid = N.tid AND S.vid = %d";
$query_result = db_query_range($query1, $vid, 0, $query_limit);
If you are using Drupal7 you may be incorrectly calling the db_query_range
function. http://api.drupal.org/api/function/db_query_range/7:
db_query_range($query, $from, $count, array $args = array(), array $options = array())
$count The number of records to return from the result set.
no results out of a query means you have no rows in your tables that match your join condition.
Have you verified that any nodes in your Drupal install have a taxonomy term from the #1 taxonomy vocabulary? Your query will result in zero rows if the #1 vocabulary is not used in any nodes.
精彩评论