Is doing it the this way acceptable?
PHP Code:
<?php
class ModelProduct extends Model {
function getProduct($product_id) {
return $this->database->query("select * from product where product_id = '" . (int)$product_id . "'");
}
function listProduct($language_id, $sort = 'pd.name', $limit = 20) {
return $this->database->query("select * from product p left join product_description pd on (p.product_id = pd.product_id) where pd.language_id = '" . (int)$language_id . "'");
}
function countProduct() {
$result = $database->database("select * from product");
return $result->countRows();
}
function searchProduct($where, $sort = 'pd.name', $limit = 20) {
$result = $this->database->query("select * from product where `" . $this->database->escape($key) . "` = '" . $this->database->escape($value) . "'");
return $result->getRows();
}
function insertProduct($data) {
$this->database->query("insert into product set quantity = '?', date_available = '?', model = '?', manufacturer_id = '?', image_id = '?', shipping = '?', price = '?', sort_order = '?', weight = '?', weight_class_id = '?', status = '?', tax_class_id = '?', date_added = now()");
$this->cache->delete('product');
return $this->database->getLastId();
}
function updateProduct($product_id, $data) {
$this->database->query("update product set quantity = ':quantity', date_available = ':date_available', model = ':model', manufacturer_id = ':manufacturer_id', image_id = ':image_id', shipping = ':shipping', price = ':price', sort_order = ':sort_order', weight = ':weight', weight_class_id = ':weight_class_id', status = ':status', tax_class_id = ':tax_class_id', date_modified = now() where product_id = '" . (int)$product_id . "'");
$this->cache->delete('product');
return $this->database->countAffected();
}
function deleteProduct($product_id) {
$this->database->query("delete from product where product_id = '" . (int)$product_id . "'");
$this->deleteDescription($product_id);
$this->deleteOption($product_id);
$this->deleteDiscount($product_id);
$this->deleteImage($product_id);
$this->deleteDownload($product_id);
$this->deleteCategory($product_id);
$this->cache->delete('product');
return $this->database->countAffected();
}
etc...
?>
Bookmarks