Jump to content
  • разработка интернет магазинов на opencart
  • доработка интернет магазинов на opencart

Отформатировать полученное значение


vvo
 Share

Recommended Posts

Приветствую

 

Не силен в php, гделаю методом проб и ошипотому чток получение инфо о товаре по api, прошу помощи

 

есть запрос

$this->db->query("SELECT product_id FROM `" . DB_PREFIX . "product` WHERE `model` LIKE $model");

получаю

{"num_rows":1,"row":{"product_id":"317"},"rows":[{"product_id":"317"}]}

 

из этого нужно взять только 317

 

чтобы полулился рилилий код:

 

$model = $this->request->get['model'];
$product_id = [----] $this->db->query("SELECT product_id FROM `" . DB_PREFIX . "product` WHERE `model` LIKE $model");

$product_info = $this->model_catalog_product->getProduct($product_id);

Link to comment
Share on other sites


  

$product_id = ???

if (isset($this->request->get['model'])) {
	$getProductByModel = $this->db->query("
		SELECT `product_id` FROM `" . DB_PREFIX . "product` WHERE `model` = '" . $this->db->escape($this->request->get['model']) . "'
	");

	if (isset($getProductByModel->row['product_id'])) {
		$product_id = $getProductByModel->row['product_id'];
	}
}

$product_info = $this->model_catalog_product->getProduct($product_id);

 

  • +1 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

On our site, cookies are used and personal data is processed to improve the user interface. To find out what and what personal data we are processing, please go to the link. If you click "I agree," it means that you understand and accept all the conditions specified in this Privacy Notice.