A
A
andizura2021-08-04 02:52:26
opencart
andizura, 2021-08-04 02:52:26

How to get all rows from a database?

There is an add-on for opencart that makes import / export of goods.
It has the ability to insert php that will be executed on processing each line.
Task: get any value from the database
There is this:

$products = $this->db->query("SELECT price FROM " . DB_PREFIX . "product_special");
$result = $products->row['price'];

Displays/gets only the first line. How to get everything? Running the output in a loop does not work, well, or I'm not doing it right In the $result

variable - the result of php execution should be displayed. The first column should have different values:
6109d5f01408c604629781.jpeg

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Ruslan Saifullin, 2021-08-04
@andizura

$products = $this->db->query("SELECT price FROM " . DB_PREFIX . "product_special");
foreach($products->rows as $raw){
         var_dump($raw['price']);
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question