1
Antoine
XOOPS and MySQL database version
  • 2005/7/1 18:11

  • Antoine

  • Friend of XOOPS

  • Posts: 112

  • Since: 2004/11/14


When I first started using XOOPS I was advised by someone to use the latest release of the 3.x series of MySQL.

Now howerver, a few months later I find myself writing modules myself and I find that there are tasks I simply cannot perform in a single query in MySQL 3.x, a big problem being the lack of subqueries. My question is:

What is the highest version of MySQL to work seamlessly with the latest 2.x XOOPS version?

2
jdseymour
Re: XOOPS and MySQL database version

I think right now any of the latest versions of the 4.0x series, there are still some issues with the 4.1x versions do to the way some things are handled. So seemlessly I would suggest 4.0x.

3
Antoine
Re: XOOPS and MySQL database version
  • 2005/7/1 20:04

  • Antoine

  • Friend of XOOPS

  • Posts: 112

  • Since: 2004/11/14


Hmm unfortunately 4.0x still doesn't support subqueries? I know this is a bit off topic but does anyone know how to this without subqueries (like in latest MySQL 3.x release?):

SELECT count(*) FROM projects WHERE project_id IN
(SELECT (*) FROM project_images) AND project_type=1

4
Mithrandir
Re: XOOPS and MySQL database version

I guess that particular query could be done with a join instead of a subquery.

SELECT count(*) FROM projectsproject_images WHERE projects.project_id project_images.project_id AND project_type=1
"When you can flatten entire cities at a whim, a tendency towards quiet reflection and seeing-things-from-the-other-fellow's-point-of-view is seldom necessary."

Cusix Software

5
Antoine
Re: XOOPS and MySQL database version
  • 2005/7/1 20:33

  • Antoine

  • Friend of XOOPS

  • Posts: 112

  • Since: 2004/11/14


SELECT count(*) FROM projectsproject_images WHERE projects.project_id project_images.project_id AND project_type=1


Unfortunaltely that doesn't work when more images belong to one project. In that case that query would effectively count the number of images belonging to all projects instead of all the projects that have at least one image belonging to them.
I have been able to solve this problem for the actual retrieval of the projects that have at least one image belong to them by doing this:

SELECT DISTINCT projects.project_id AS project_idproject_nameproject_descriptionproject_typeproject_locationproject_detailsproject_statusproject_salesinfoproject_rentinfoproject_enrollmentproject_areacode
FROM projects
project_images
WHERE projects
.project_id=project_images.project_id
AND project_type=1
ORDER BY project_name


This example works cause the image_id field is not included in the SELECT and therefore generates duplicate records for each image belonging to a project. DISTINCT will get rid of these.

But not when using something like:

SELECT DISTINCT count(projects.project_idFROM projectsproject_images WHERE projects.project_id project_images.project_id AND project_type=1


In this case MySQL first basically counts all the records when combining the two tables which generates a record for each image linked to a project. That results in a single record and last MySQL applies DISTICT which by then is naturally too late since there is but one record holding a field with an incorrect project count.

This problem is really nagging me. Tried all kinds of JOINS to solve it but haven't come up with any solution. Maybe I'm missing something.

6
Antoine
Re: XOOPS and MySQL database version
  • 2005/7/2 15:34

  • Antoine

  • Friend of XOOPS

  • Posts: 112

  • Since: 2004/11/14


/mini-bump

Since I'm on a rather strict deadline I have used a workaround like this:

SELECT DISTINCT (projects.project_id)
FROM projectsproject_images
WHERE projects
.project_id project_images.project_id
AND project_type='1'


Later getting the row count with:
$count $this->db->getRowsNum($result);
return 
$count;


Not the prettiest of solutions but it does the job. Still very much like to know if anyone know how to do it with a query.

Login

Who's Online

143 user(s) are online (86 user(s) are browsing Support Forums)


Members: 0


Guests: 143


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Apr 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits