Skip to content

Instantly share code, notes, and snippets.

@marcghorayeb
Created February 3, 2012 16:52
Show Gist options
  • Save marcghorayeb/1731092 to your computer and use it in GitHub Desktop.
Save marcghorayeb/1731092 to your computer and use it in GitHub Desktop.
Lithium subquery
public function allParameters($product) {
$conditions = array('subtype_id' => $product->subtype_id);
$order = array('pos' => 'ASC');
$with = array(
'ParametersIndexes' => array(
'conditions' => array(
'product_id_key' => $product->id
)
)
);
return Parameters::all(compact('conditions', 'order', 'with'));
}
$SQL= "SELECT *
FROM `sc_param` AS `Parameters`
LEFT JOIN `sc_param_index` AS `ParametersIndexes`
ON `Parameters`.`id` = `ParametersIndexes`.`param_id`
WHERE `subtype_id` = 5
ORDER BY `Parameters`.`pos` ASC"
$SQL= "SELECT *
FROM `sc_param` AS `Parameters`
LEFT JOIN `sc_param_index` AS `ParametersIndexes`
ON `Parameters`.`id` = `ParametersIndexes`.`param_id`
WHERE `subtype_id` = 5 AND sc_param_index = 2133 <----
ORDER BY `Parameters`.`pos` ASC"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment