I am trying to call the make_id from the model controller, but every time I just get illegal string, please help me with this, what I am doing wrong?
code from model :
public function getTotalModelsByMark($mark_id) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "models WHERE mark_id = '" . (int)$mark_id . "'");
return $query->row;
}
code from controller :
$this->load->model('catalog/models');
$data['models'] = array();
$results = $this->model_catalog_models->getTotalModelsByMark($mark_info['mark_id']);
foreach ($results as $result) {
$data['models'][] = array(
'model_id' => $result['model_id'],
'name' => $result['name'],
'mark_id' => $result['mark_id'],
'status' => $result['status'],
'category' => $result['category'],
'edit' => $this->url->link('catalog/models/edit', 'token=' . $this->session->data['token'] . '&model_id=' . $result['model_id'] . $url, true)
);
}
code from view :
<?php if ($models) { ?>
<?php foreach ($models as $model) { ?>
<tr>
<td class="text-center"><?php if (in_array($model['model_id'], $selected)) { ?>
<input type="checkbox" name="selected[]" value="<?php echo $model['model_id']; ?>" checked="checked" />
<?php } else { ?>
<input type="checkbox" name="selected[]" value="<?php echo $model['model_id']; ?>" />
<?php } ?></td>
<td class="text-left"><?php echo $model['name']; ?></td>
<td class="text-left"><?php echo $model['mark_id']; ?></td>
<td class="text-right"><?php echo $model['status']; ?></td>
<td class="text-right"><?php echo $model['category']; ?></td>
<td class="text-right"><a href="<?php echo $model['edit']; ?>" data-toggle="tooltip" title="<?php echo $button_edit; ?>" class="btn btn-primary"><i class="fa fa-pencil"></i></a></td>
</tr>
<?php } ?>
<?php } else { ?>
<tr>
<td class="text-center" colspan="4"><?php echo $text_no_results; ?></td>
</tr>
<?php } ?>
When don't have results I get the $text_no_results with no errors, but when I have records to show I get Illegal string offset 'model_id''name' 'mark_id' 'status' 'category,'from this morning I trying to get this fix, but I can't, this is open cart.