markamace1 / libstats

Automatically exported from code.google.com/p/libstats
GNU General Public License v2.0
1 stars 0 forks source link

Problems with READ types modifications #6

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. I followed the steps at http://code.google.com/p/libstats/wiki/AddField

What is the expected output? What do you see instead?
The "Questions By READ Type" report doesn't work.  By uncommenting the
debugging statement around line 44 of reports/ByReadType.php (see the full
output in the attached file), I see that MySQL is reporting a syntax error
with the "SELECT COUNT..." query, but I can't find anything wrong with the
query.  It certainly doesn't appear to be any different than the query
executed by ByPatronType.php.

What version of the product are you using? On what operating system?
1.0.6 on RHEL5

Please provide any additional information below.

Original issue reported on code.google.com by cgriml...@gmail.com on 9 Jul 2009 at 8:52

Attachments:

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Using the mysql client, if I execute the "SELECT COUNT..." query (minus the 
WHERE
clause) on the patron_types table, I get results.  If I execute the same query 
with
all instances of "patron" changed to "read", I get a syntax error.  I must have 
made
a mistake somewhere else, but I can't seem to track it down.

mysql> select count(questions.question) as questions, patron_types.patron_type 
as
patrons from questions join patron_types on (questions.patron_type_id =
patron_types.patron_type_id) group by patrons;
+-----------+---------------------+
| questions | patrons             |
+-----------+---------------------+
|      2144 | Community           |
|      1179 | Faculty/Staff       |
|      2450 | Student - Graduate  |
|     23193 | Student - Undergrad |
|      1421 | Unknown             |
+-----------+---------------------+
5 rows in set (0.14 sec)

mysql> select count(questions.question) as questions, read_types.read_type as 
reads
from questions join read_types on (questions.read_type_id = 
read_types.read_type_id)
group by reads;
ERROR 1064 (42000): 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 
'reads from
questions join read_types on (questions.read_type_id = read_types.rea' at line 1
mysql> 

Original comment by cgriml...@gmail.com on 10 Jul 2009 at 6:57

GoogleCodeExporter commented 9 years ago
Problem solved.

MySQL doesn't like "reads" as the JOIN alias.  I changed it to "readtypes" and 
it all
works.

So, line 27 should look something like this:

    $fullQuery = "SELECT COUNT(questions.question) as questions, read_types.read_type
as readtypes
                        FROM questions
                        JOIN read_types ON
                        (questions.read_type_id = read_types.read_type_id)
                        $sql
                        GROUP BY readtypes";

And line 74 should be changed to match:

<td>{$report["readtypes"]}</td>

Original comment by cgriml...@gmail.com on 10 Jul 2009 at 7:09