1 SIMPLE tblbook ALL PRIMARY NULL NULL NULL 2669 Using where; Using temporary; Using filesort 1 SIMPLE sometbl ref system_product_id,system_section_id system_product_id 9 modx_profile.tblbook.system_product_id 1 Using where 1 SIMPLE sometbl ref system_brand_id system_brand_id 9 modx_profile.tblbook.system_brand_id 1 Using where 1 SIMPLE tblbooks ALL NULL NULL NULL NULL 2669 Using where; Using join buffer
<?php
$path = MODX_CORE_PATH . 'components/modx_tblbook/';
$result = $modx->addPackage('modx_tblbook',$path . 'model/','modx_');
$divider = "/";
if ((isset($_GET['comid'])!=null)||($_GET['comid'])!=0){
$urlresult = $_GET['comid'];
}
$query = $modx->newQuery('Tblbook');
$query->select(array (
'Tblbook.system_product_id',
'Tblbook.system_brand_id',
'Tblbook.brand_name',
'Tbooks.content',
'Tblbook.company',
'Tblbook.form_class',
'Tgen.system_generic_id',
'Tsec1.section1_id',
'Tsec2.section2_id',
'Tsec3.section3_id',
'Tsec4.section4_id'
));
$query->innerJoin('Tblbooks', 'Tbooks', array("Tblbook.system_brand_id = Tbooks.system_brands_id"));
$query->innerJoin('Tblbrandgenericgroupsms','Tgen',array("Tblbook.system_brand_id = Tgen.system_brand_id"));
$query->innerJoin('Tblproductsections', 'Tprodsec', array(" Tblbook.system_product_id = Tprodsec.system_product_id"));
$query->leftJoin('Tblsection', 'Tsec', array(" Tprodsec.system_section_id = Tsec.system_section_id"));
$query->leftJoin('Tblsection1', 'Tsec1', array(" Tsec.system_section1_id = Tsec1.system_section1_id"));
$query->leftJoin('Tblsection2', 'Tsec2', array(" Tsec.system_section2_id = Tsec2.system_section2_id"));
$query->leftJoin('Tblsection3', 'Tsec3', array(" Tsec.system_section3_id = Tsec3.system_section3_id"));
$query->leftJoin('Tblsection4', 'Tsec4', array(" Tsec.system_section4_id = Tsec4.system_section4_id"));
$query->where(array("Tblbook.system_company_id" => "$urlresult"));
$query->groupBy('brand_name');
$query->sortBy('brand_name','ASC');
$products = $modx->getCollection('Tblbook',$query);
foreach($products as $product){
some code here......
return $output;
select tblbook.system_product_id,[ed. note: johnrobert27 last edited this post 13 years, 3 months ago.]
tblbook.system_brand_id,
tblbook.brand_name,
tblbooks.content,
tblbook.company,
tblbook.form_class,
tblsection1.section1_id,
tblsection2.section2_id,
tblsection3.section3_id,
tblsection4.section4_id,
tblbrandgenericgroupsms.system_generic_id
From tblbook
INNER Join tblbooks ON tblbook.system_brand_id = tblbooks.system_brands_id
INNER JOIN tblproductsections ON tblbook.system_product_id = tblproductsections.system_product_id
INNER JOIN tblbrandgenericgroupsms ON tblbook.system_brand_id = tblbrandgenericgroupsms.system_brand_id
LEFT JOIN tblsection ON tblproductsections.system_section_id = tblsection.system_section_id
LEFT JOIN tblsection1 ON tblsection.system_section1_id = tblsection1.system_section1_id
LEFT JOIN tblsection2 ON tblsection.system_section2_id = tblsection2.system_section2_id
LEFT JOIN tblsection3 ON tblsection.system_section3_id = tblsection3.system_section3_id
LEFT JOIN tblsection4 ON tblsection.system_section4_id = tblsection4.system_section4_id
WHERE tblbook.system_company_id = '20100106' GROUP BY tblbook.brand_name;