function searchRecords($searchKey, $fields, $limit) { $condition = "where ("; foreach ($fields as $key => $value) { if ($key == 0) { $condition = $condition . $value . " like '%" . $searchKey . "%'"; } else { $condition = $condition . "or " . $value . " like '%" . $searchKey . "%' "; } } if (!strstr(strtoupper($limit), 'ORDER')) { $sql = sprintf("select * from %s %s;", $this->MERGEDRECEIPT_TABLE, $condition . ") and status != 'cancelled' ORDER BY receiptID DESC " . $limit); } else { $limit = str_replace("WHERE", "and", $limit); $sql = sprintf("select * from %s %s;", $this->MERGEDRECEIPT_TABLE, $condition . ") " . $limit); } $this->setDB(); $this->db->query($sql); while ($this->db->next_record()) { $receipt = new MergedReceipt(); $receipt->selectRecord($this->db->f("receiptID")); $this->arrayList[] = $receipt; } if (count($this->arrayList) > 0) { //$this->setDomDocument(); return true; } else { return false; } }