Welcome, Guest
Username: Password: Remember me

TOPIC: Select data from multiple tables based on user id

Select data from multiple tables based on user id 17 Feb 2012 22:13 #1357

  • antzog
  • antzog's Avatar
  • Offline
  • New Member
  • Posts: 9
  • Karma: 0
Hi,

I believe this is possible using Cook but if it requires additional coding then please do let me know.

My site for this component has three main tables:

The standard joomla users table

A 'Members' table which contains other information about my members/users and in which the rows share a common id with the joomla users table. One of the main bits of information stored in the members table is their university code (a 4 letter code).

I also have a table 'Universities' which has the full name of all universities, their related university code and other uni information.

I wish to make it so users are able to login to the site and view a frontend Fly which displays their membership details (from the members table) and university name, uni code and other info (from the universities table).

To do this the model must check the joomla id of the user and fetch the 'university code' of that user from the members table (members.id = user.id) then display only the university information which is in the 'universities' table against the row containing that users university code.

I have taught myself basic php in the past and done this kind of query with something like the following:

$query = "SELECT * FROM #__users, #__members , #__universities WHERE #__users.id = '$user->id' AND #__users.id = #__members.id AND #__members.uni_code = #__universities.uni_code ";

Within Cook I am wondering how I can set up my tables using FK and Joomla User field so that I can recreate a query to fetch information something like the above example.

Admin; I am trying to create this in Cook/Testproj at the moment.

Any suggestions from other Cook users very welcome as I think this should be fairly straight forward but have not been able to get it working so far.. I know admin is very busy though so personal projects / tuition may not be top priority!

Looking forward to hearing your suggestions.

Beaker
The administrator has disabled public write access.

Re: Select data from multiple tables based on user id 04 Mar 2012 03:28 #1501

  • antzog
  • antzog's Avatar
  • Offline
  • New Member
  • Posts: 9
  • Karma: 0
Anyone??
The administrator has disabled public write access.

Re: Select data from multiple tables based on user id 09 Mar 2012 17:09 #1539

  • BTB300
  • BTB300's Avatar
  • Offline
  • Moderator
  • Posts: 415
  • Thank you received: 132
  • Karma: 47
You can try to recreate the query in models/fields
Have a look there
You will see a number of "parts" of a query definition
Search for the username "etc" you will find a [solved] ticket regarding query
That will give you a starting point to work from

I do believe that user based views is something many of us are trying to achieve...

The modifications in builder in the past few days are certainly making it much easier to perform queries inside the cook environment

Admin is forever adding functionality and I believe that it is on his priority list for user based views

Hope it helps in the mean time

For now create a working mysql query then dissect and place the relevant "snipits" in the cook query

Just watch out for periods "." it's easy to miss one when modifying the query
The administrator has disabled public write access.
The following user(s) said Thank You: admin, antzog
Time to create page: 0.138 seconds

Get Started