S
S
sharelove2021-01-18 10:51:53
opencart
sharelove, 2021-01-18 10:51:53

Why does the query return a column and not a row and at the same time display only the very first character from the cell?

Controller:

foreach($this->model_extension_module_track->getCustomer($code) as $result){
    $data['customers'][] = array(
        'id' => $result['id']
     );
}


Model:
class ModelExtensionModuleTrack extends Model {
  public function getCustomer($customer_id) {
    $query = $this->db->query("SELECT DISTINCT * FROM `oc_customers_track` WHERE `id` = '" . (int)$customer_id . "'");

    return $query->row;
  }
}


SQL Table:
60053dcadf7a9148345884.png

Result:
60053e0677dc7112868846.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
sharelove, 2021-01-19
@sharelove

It turned out the problem is that I returned one line

- return $query->row;

+ return $query->rows;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question