Problem with ORDER BY LIMIT in MySQL 4.1.22

Please support our Perl advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Jun 2009
Posts: 1
Reputation: trilbies is an unknown quantity at this point 
Solved Threads: 0
trilbies trilbies is offline Offline
Newbie Poster

Problem with ORDER BY LIMIT in MySQL 4.1.22

 
0
  #1
Jun 24th, 2009
Hello. I am new and hope to find an answer to my query.

I run a classified database and have been doing so for quite a few years, I recently upgraded the Plesk CP on my server and suddenly a problem appeared with the way the DB is returning the queries.

I am currently running Perl 5 with MySQL 4.1.22

My old code was like this (trimmed code for simplification):

  1. use DBI;
  2.  
  3. $dbh = DBI->connect ("DBI:mysql:host=localhost;database=$SQL_DATABASE_NAME",
  4. "$SQL_DATABASE_USERNAME",
  5. "$SQL_DATABASE_PASSWORD", {printError => 0}) or die "Cannot connect to server: $DBI::errstr (DBI::err)";
  6.  
  7. $order_by = "token_key" if (!$order_by);
  8.  
  9. $sth = $dbh->prepare (qq~SELECT * FROM $adverts_database WHERE MATCH (advert_title,pedigree,text,area) ORDER BY ? $show LIMIT $length~);
  10.  
  11. $sth->execute("$order_by");

The above used to work flawlessly, but since I upgraded the CP, the database stoped listing the adverts according to "order_by" and apparently listing them in icremental order from the db.

I had to correct the code like this to sort it out:

  1. $sth = $dbh->prepare (qq~SELECT * FROM $adverts_database WHERE MATCH (advert_title,pedigree,text,area) ORDER BY token_key $show LIMIT $length~);
  2.  
  3. $sth->execute();

I tried everything before arriving this this solution like puttingthe ? in quotes, removing the quotes around $order_by in the execute->() but nothing worked.

I am quite puzzled by this and having done some research on the web I initially though that it was caused by a MySQL bug affecting ODRER BY with LIMIT in certain JOIN operation, but this is nothing of the sort.

I am fairly shure that it is down to the CP upgrade as no activities took place other than the Control Panel upgrade (to Plesk 8.6 from 8.4)

Any feedback about this could be useful.

Many thanks.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC