Executes the given SQL query and returns only one (the first) row
public QuerySingleRow ( string $sql ) : object | ||
$sql | string | The query string should not end with a semicolon |
리턴 | object | PHP resource object containing the first row or FALSE if no row is returned from the query |
function getLayeredFilter() { $sql = "SELECT filters FROM ps_layered_filter WHERE name = 'VisionFilter'"; $db = new MySQL(); return $db->QuerySingleRow($sql); }
function getProductBasePrice($id_product) { $sql = "SELECT * FROM ps_product WHERE id_product = {$id_product}"; $db = new MySQL(); $result = $db->QuerySingleRow($sql); if ($db->RowCount() > 0) { return $result->price; } else { return -1; } }
/** * Metodo utilizzato per recuperare id del produttore a partire dal nome * * @param String $produttore Nome del produttore * @return Int Id del produttore presente nel db */ function getIDManufacturer($produttore) { $sql = "SELECT id_manufacturer FROM ps_manufacturer WHERE name = '{$produttore}'"; $db = new MySQL(); $result = $db->QuerySingleRow($sql); return $result->id_manufacturer; }
function getIdProductFromCode($code) { if (isset($this->_MAPPING_PRODOTTI_CODE_ID[$code])) { return $this->_MAPPING_PRODOTTI_CODE_ID[$code]; } else { return null; } $db = new MySQL(); $sql = "SELECT id_product FROM ps_product WHERE code = '{$code}'"; $result = $db->QuerySingleRow($sql); return $result->id_product; }
function getIdUserFromCode($code) { $db = new MySQL(); $sql = "SELECT id_customer FROM ps_customer WHERE code = '{$code}'"; $result = $db->QuerySingleRow($sql); return $result->id_customer; }
/** * Metodo utilizzato per recuperare ultimo valore di position all'interno della tabella ps_category_shop * * @return int $position Ultimo valore di position presente */ function getCategoryShopLastPosition() { $db = new MySQL(); $sql = "SELECT position FROM ps_category_shop WHERE id_category > 2 ORDER BY position DESC"; $result = $db->QuerySingleRow($sql); if ($db->RowCount() > 0) { return $result->position + 1; } else { return 1; } }
/** * Metodo per recuperare la stringa ISO_CODE della provincia del customer Prestashop * * @param int $id_state Identificativo della provincia associata al customer * @return ISO_CODE Sigla della provincia del customer PRestashop * */ function getStateFromId($id_state) { $query = "SELECT * FROM ps_state WHERE id_state = {$id_state}"; $db = new MySQL(); $result = $db->QuerySingleRow($query); return $result->iso_code; }