Merge pull request #22518 from hregis/fix_avoid_error_with_postgresql
FIX remove db object for avoid error with postgresql
This commit is contained in:
commit
2ba4993666
@ -75,7 +75,7 @@ if ($prodattr->fetch($id) < 0) {
|
||||
|
||||
$prodattrval = new ProductAttributeValue($db);
|
||||
|
||||
$res = $prodattrval->fetchAllByProductAttribute($id);
|
||||
$res = $prodattrval->fetchAllByProductAttribute($id, false, 1);
|
||||
|
||||
if ($res == -1) {
|
||||
print json_encode(array(
|
||||
|
||||
@ -107,9 +107,10 @@ class ProductAttribute extends CommonObject
|
||||
/**
|
||||
* Returns an array of all product variants
|
||||
*
|
||||
* @return ProductAttribute[]
|
||||
* @param int $returnonlydata 0: return object, 1: return only data
|
||||
* @return ProductAttribute[]
|
||||
*/
|
||||
public function fetchAll()
|
||||
public function fetchAll($returnonlydata = 0)
|
||||
{
|
||||
$return = array();
|
||||
|
||||
@ -118,7 +119,12 @@ class ProductAttribute extends CommonObject
|
||||
$query = $this->db->query($sql);
|
||||
if ($query) {
|
||||
while ($result = $this->db->fetch_object($query)) {
|
||||
$tmp = new ProductAttribute($this->db);
|
||||
if (empty($returnonlydata)) {
|
||||
$tmp = new ProductAttribute($this->db);
|
||||
} else {
|
||||
$tmp = new stdClass();
|
||||
}
|
||||
|
||||
$tmp->id = $result->rowid;
|
||||
$tmp->ref = $result->ref;
|
||||
$tmp->ref_ext = $result->ref_ext;
|
||||
|
||||
@ -99,11 +99,12 @@ class ProductAttributeValue extends CommonObject
|
||||
/**
|
||||
* Returns all product attribute values of a product attribute
|
||||
*
|
||||
* @param int $prodattr_id Product attribute id
|
||||
* @param bool $only_used Fetch only used attribute values
|
||||
* @return ProductAttributeValue[]
|
||||
* @param int $prodattr_id Product attribute id
|
||||
* @param bool $only_used Fetch only used attribute values
|
||||
* @param int $returnonlydata 0: return object, 1: return only data
|
||||
* @return ProductAttributeValue[]
|
||||
*/
|
||||
public function fetchAllByProductAttribute($prodattr_id, $only_used = false)
|
||||
public function fetchAllByProductAttribute($prodattr_id, $only_used = false, $returnonlydata = 0)
|
||||
{
|
||||
$return = array();
|
||||
|
||||
@ -130,7 +131,12 @@ class ProductAttributeValue extends CommonObject
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
while ($result = $this->db->fetch_object($query)) {
|
||||
$tmp = new ProductAttributeValue($this->db);
|
||||
if (empty($returnonlydata)) {
|
||||
$tmp = new ProductAttributeValue($this->db);
|
||||
} else {
|
||||
$tmp = new stdClass();
|
||||
}
|
||||
|
||||
$tmp->fk_product_attribute = $result->fk_product_attribute;
|
||||
$tmp->id = $result->rowid;
|
||||
$tmp->ref = $result->ref;
|
||||
|
||||
@ -467,7 +467,7 @@ if (!empty($id) || !empty($ref)) {
|
||||
}
|
||||
|
||||
if ($action == 'add') {
|
||||
$prodattr_all = $prodattr->fetchAll();
|
||||
$prodattr_all = $prodattr->fetchAll(1);
|
||||
|
||||
if (!$selected) {
|
||||
$selected = $prodattr_all[key($prodattr_all)]->id;
|
||||
@ -478,7 +478,6 @@ if (!empty($id) || !empty($ref)) {
|
||||
foreach ($prodattr_all as $each) {
|
||||
$prodattr_alljson[$each->id] = $each;
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
Loading…
Reference in New Issue
Block a user