Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Critical
-
Resolution: Cannot Reproduce
-
Affects Version/s: 1.9.4
-
Fix Version/s: 1.9.5
-
Component/s: Database SQL/XMLDB
-
Labels:None
-
Environment:MS Windows Server 2003
-
Database:Microsoft SQL
-
Difficulty:Difficult
-
Affected Branches:MOODLE_19_STABLE
-
Fixed Branches:MOODLE_19_STABLE
Description
When searching a forum the adapter seems to crash and return no recordset. If i run the offending SQL query directly on the MS SQL server it runs fine so i presume its a driver based problem.
The search will sometimes work and sometimes not; This seems to be rather intermittent and searches of 2 chars will often work where as larger words always fail.
I created a quick PHP page to test this obviously the list of forums will need to be changed to test this correctly.
<?PHP
require_once('../../config.php');
require_once('lib.php');
$sql = "SELECT p.*, d.forum, u.firstname, u.lastname, u.email, u.picture, u.imagealt FROM mdl_forum_posts p, mdl_forum_discussions d, mdl_user u WHERE ((p.message LIKE '%finished%') OR (p.subject LIKE '%finished%') ) AND p.discussion = d.id AND p.userid = u.id AND ((d.forum IN (89,90,91,92,93,227,294,297,79,78,87,88,254,303,288,95,96,94,97,76,98))) ORDER BY p.modified DESC";
if($records = get_records_sql($sql)){
echo "has records<br>";
}else{
echo "no records<br>";
}
$sql = "SELECT mu.id, mu.firstname FROM mdl_user mu";
if($records = get_records_sql($sql)){ echo "has records<br>"; } }else{
echo "no records 1<br>";
}
?>
i found that removeing everything after order by caused the first query to return ok but the second then fails. I then found that removeing the IN () completley made both querys return correctly.
I hope you can shed some light on this.
assigning correctly. - also Steven - you don't seem to have mentioned the method of connecting to MS SQL - are you using the FreeTDS method?