/** * Retorna las ofertas marcadas como especial */ function getOfferSpecial2() { $db =& JFactory::getDBO(); $query = "SELECT p.*, pf.file_url FROM\n\t\t#__cp_category c JOIN \n\t\t(#__cp_products p JOIN\n\t\t#__cp_product_files pf ON pf.product_id = p.product_id)\n\t\tON c.category_id=p.category_id \n\t\tWHERE p.`featured` = 1 AND p.`published` = 1 " . getWhere() . " GROUP BY p.product_id"; $db->setQuery($query); $rows = $db->loadObjectList(); return $rows; }
/** * Retorna las ofertas por tipo de turismo */ function getOffers($tourismType) { $db =& JFactory::getDBO(); //$query = "SELECT p.* FROM $query = "SELECT p.*,(select pf.file_url from #__cp_product_files pf where pf.product_id = p.product_id limit 1 ) as img FROM\n\t\t#__cp_category c JOIN\t\n\t\t(#__cp_products p JOIN\n\t\t#__cp_product_tourismtype ptt ON \n\t\tptt.product_id=p.product_id JOIN\n\t\t#__cp_tourismtype tt ON \n\t\tptt.tourismtype_id=tt.tourismtype_id)\n\t\tON c.category_id=p.category_id\t\t\n\t\tWHERE 1 "; if ($tourismType != '') { $query .= " AND ptt.tourismtype_id=" . $tourismType; } $query .= "\tAND p.`published` = 1 " . getWhere() . " AND tt.`published` = 1"; $db->setQuery($query); $rows = $db->loadObjectList(); return $rows; }
function select($inQuery = '') { global $table; // built limit clause $lim = (int) getPostString("limit"); $off = (int) getPostString("offset"); $limit = $lim || $off ? " LIMIT {$off}, {$lim}" : ""; // build order by clause $desc = (bool) getPostString("desc"); $ob = getOrderBy(); $orderby = $ob ? " ORDER BY `" . $ob . "`" . ($desc ? " DESC" : "") : ""; // build query $query = $inQuery ? $inQuery : "SELECT * FROM `{$table}`" . getWhere() . $orderby . $limit; // execute query if (!($result = mysql_query($query))) { error("failed to perform query: {$query}. " . mysql_error()); } // fetch each result row return getArray($result); }
return "\r\n\t\t\tA.id_trouble_tickets IN (\r\n\t\t\t\tSELECT ttd_ticket_id \r\n\t\t\t\tFROM trouble_ticket_data\r\n\t\t\t\tWHERE ttd_field_id = {$fieldid} AND ttd_string_value = '{$cat}'\r\n\t\t\t)"; } // pegando o id do customer no session $customerID = mySx('customerID'); $profile = mySx('profile'); $data = myGet('data'); $aFilters = array(); $aFilters[] = "DATE(A.tkt_open_date) <= '{$data}'"; $aFilters[] = "A.tkt_customer_id = {$customerID}"; $cat = myGet('cat', ''); if ($cat) { $aFilters[] = getWhere($profile['cat'], $cat); } $serv = myGet('serv', ''); if ($serv) { $aFilters[] = getWhere($profile['serv'], $serv); } $stat = myGet('stat', ''); if ($stat) { $aFilters[] = "A.tkt_status_name = '" . $stat . "'"; } else { $aFilters[] = "DATE(IFNULL(A.tkt_close_date,NOW())) >= '{$data}'"; } $sFilters = implode(' AND ', $aFilters); // buscando todos os tickets $sQuery = "\r\n\t\tSELECT A.tkt_id, A.id_trouble_tickets, (CASE WHEN B.ttd_field_id = {$profile['lat']} THEN 'lat' ELSE 'lng' END) ttd_field, B.ttd_string_value\r\n\t\tFROM (\r\n\t\t\tSELECT tkt_id, max(id_trouble_tickets) id_trouble_tickets\r\n\t\t\tFROM trouble_tickets A\r\n\t\t\tWHERE {$sFilters}\r\n\t\t\tGROUP BY tkt_id\r\n\t\t) A\r\n\t\tLEFT JOIN trouble_ticket_data B ON A.id_trouble_tickets = B.ttd_ticket_id AND B.ttd_field_id IN ({$profile['lat']},{$profile['lng']})\r\n\t"; $busca = sqlQuery('main', $sQuery); $marks = array(); $aIDs = array(); foreach ($busca['rows'] as $x) { $id = $x['tkt_id'];
function getRecords($con, $where, $orderby, $limit, $offset, $pagesize, &$rowcount) { $sql_where = getWhere($where); $sql_orderby = getOrderBy($orderby, $count); $sql_limit = getLimit($limit, 0); $sql_page = getLimit($pagesize, $offset); if ($limit) { if ($pagesize) { $sql = "SELECT * FROM phones " . $sql_where . $sql_orderby . $sql_limit; $sql = "select * from ( " . $sql . " ) a " . $sql_page; $records = fetchRows($con, $sql); if (!$records) { return false; } $rc_sql = "SELECT 1 FROM phones " . $sql_where . $sql_limit; $rc_sql = "select count(*) AS rowcount from ( " . $rc_sql . " ) rc"; $rowcount = fetchRowCount($con, $rc_sql); if (!$rowcount) { return false; } return $records; } $sql = "SELECT * FROM phones " . $sql_where . $sql_orderby . $sql_limit; $records = fetchRows($con, $sql); $rowcount = count($records); return $records; } if ($pagesize) { $sql = "SELECT * FROM phones " . $sql_where . $sql_orderby . $sql_page; $records = fetchRows($con, $sql); if (!$records) { return false; } $rc_sql = "SELECT 1 FROM phones " . $sql_where; $rc_sql = "select count(*) AS rowcount from ( " . $rc_sql . " ) rc"; $rowcount = fetchRowCount($con, $rc_sql); if (!$rowcount) { return false; } return $records; } $sql = "SELECT * FROM phones " . $sql_where . $sql_orderby; $records = fetchRows($con, $sql); if (!$records) { return false; } $rowcount = count($records); return $records; }
// get index row - i.e. user click to sort $sord = $_REQUEST['sord']; // get the direction $grp = $_REQUEST['grp']; // get the Group By if (!$sidx) { $sidx = 1; } if ($limit == 0) { $limit = 10; } if ($page == null) { $page = 0; } if (isset($_REQUEST['_search']) && strlen($_REQUEST['_search']) > 0) { $r = getWhere($_REQUEST['_search']); if (strlen($r) > 0) { if (strlen($where) > 0) { $where = $where . " AND {$r}"; } else { $where = " {$r} "; } } } $where = trim($where); $n1 = strlen($where); if (substr($where, 0, 1) == "(" && substr($where, $n1 - 1, $n1) == ")") { //$where=substr($where,1,$n1-2); } $where1 = trim($where); $nn = strpos(strtolower($where1), " group by ");