Re: [jgen] Front End MVC display the value of three differents tables

168 views
Skip to first unread message

Michael Babker

unread,
Jul 30, 2012, 1:35:30 PM7/30/12
to joomla-de...@googlegroups.com
Try two separate join statements instead of doing it in one.  com_content has a couple examples to work with.

-Michael

Please pardon any errors, this message was sent from my iPhone.

On Jul 30, 2012, at 8:51 AM, Bruno Oliveira <bmm.deo...@gmail.com> wrote:

Hi, I want create a front end that allows to me display the values of three differents tables.

Rigth now, I have a little piece of code that allows me display the value of two differents tables.

$kiosk_id = JRequest::getInt('id');

$db = $this->getDbo();
$query = $db->getQuery(true);

$query->select('t.*, a.box_id, a.box_date_connection, a.box_date_storage, a.box_obs, a.box_version, a.box_version_date, a.box_placa_mennekes, a.box_keyboard_version, a.box_downgrade_CPU, a.box_IP');
$query->from('#__carregadores_kiosks AS t');
$query->join('LEFT', '#__carregadores_boxs AS a USING(box_id)');
$query->where("t.kiosk_id = '{$kiosk_id}'");
$db->setQuery($query);
$row = $db->loadObject();

What are the changes that I must do for that can display the values of three different table?
My three differents tables are: #__carregadores_kiosks
                                            #__carregadores_boxs
                                            #__carregadores_pens
I try do the following change but without any positive results

$query->join('LEFT', '#__carregadores_boxs AND #__carregadores_pens AS a USING(box_id, pen_id)'); 

Any one know what I must do?

--
You received this message because you are subscribed to the Google Groups "Joomla! General Development" group.
To view this discussion on the web, visit https://groups.google.com/d/msg/joomla-dev-general/-/A7DeGxjeeWIJ.
To post to this group, send an email to joomla-de...@googlegroups.com.
To unsubscribe from this group, send email to joomla-dev-gene...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/joomla-dev-general?hl=en-GB.

Bruno Oliveira

unread,
Jul 30, 2012, 5:02:58 PM7/30/12
to joomla-de...@googlegroups.com
Sorry, but I don«t understand how I do this separation.

You can write a piece of code please?



2012/7/30 Michael Babker <mba...@flbab.com>



--
Bruno Oliveira
bmm.deo...@gmail.com

Telm.: +351 916 412 058


Bruno Oliveira

unread,
Aug 12, 2012, 3:32:27 PM8/12/12
to joomla-de...@googlegroups.com
Don't Work :(
Any Ideas? I had already tried some exmples from the com_content folder but I don't understand that.

I only want display three differents tables in one view =(

On Saturday, August 4, 2012 1:55:02 PM UTC+1, dhanpatsaran wrote:
use select and join twice -

$query->select('a.box_id, a.box_date_connection, a.box_date_storage.....');
$query->join('LEFT', '#__carregadores_boxs AS a USING(box_id)');

and for the second join again use -

$query->select('p.pen_id');
$query->join('LEFT', '#__carregadores_pens AS p USING(pen_id)');
> To unsubscribe from this group, send email to joomla-dev-general+unsub...@googlegroups.com.
>
>
> For more options, visit this group at http://groups.google.com/group/joomla-dev-general?hl=en-GB.
>
>
>
>
>
>
>
>
>
>
> --
>
> You received this message because you are subscribed to the Google Groups "Joomla! General Development" group.
>
> To post to this group, send an email to joomla-de...@googlegroups.com.
>
> To unsubscribe from this group, send email to joomla-dev-general+unsub...@googlegroups.com.

elin

unread,
Aug 13, 2012, 9:13:28 PM8/13/12
to joomla-de...@googlegroups.com
The docblock gives this example with a b and c

Bruno Oliveira

unread,
Aug 19, 2012, 4:26:07 PM8/19/12
to joomla-de...@googlegroups.com
Hi guys (again),

I try your suggestions and I haven't yet good results.

<?php
defined( '_JEXEC' ) or die;

jimport('joomla.application.component.model');

class CarregadoresModelKiosk extends JModel
{
public function getItem()
{
$kiosk_id = JRequest::getInt('id');

$db = $this->getDbo();
$query = $db->getQuery(true);

$query->select('t.*, a.box_id, a.box_date_connection, a.box_date_storage, b.pen_id, b.pen_IMEI');
$query->join('LEFT', '#__carregadores_boxs AS a USING(box_id)');
$query->join('LEFT', '#__carregadores_pens AS b USING(pen_id)');
$query->from('#__carregadores_kiosks AS t');
$query->where("t.kiosk_id = '{$kiosk_id}'");
$db->setQuery($query);
$row = $db->loadObject();
return $row;
}
}

I can't see what I'm doing wrong.
If I put this code, the front end view don't load  the values of the db.
If I delete the parameters  "b.pen_id, b.pen_IMEI" and the line $query->join('LEFT', '#__carregadores_pens AS b USING(pen_id)') the front end show to me the parameters that are in the DB #__carregadores_boxs and #__carregadores_kiosks.

Someone have more suggestions?

With my best regards,
Bruno Oliveira

2012/8/14 elin <elin....@gmail.com>
To view this discussion on the web, visit https://groups.google.com/d/msg/joomla-dev-general/-/imh7_lup14MJ.

To post to this group, send an email to joomla-de...@googlegroups.com.
To unsubscribe from this group, send email to joomla-dev-gene...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/joomla-dev-general?hl=en-GB.



--
Bruno Oliveira
bmm.deo...@gmail.com

Telm.: +351 916 412 058


elin

unread,
Aug 19, 2012, 7:56:26 PM8/19/12
to joomla-de...@googlegroups.com
What does the generated query look like? Does it match the query you have that works if you run it directly icn your database?
Did you try it the way it is in the do blocks?

Elin
Reply all
Reply to author
Forward
0 new messages