I make a remake of an extension so I stuck in the last work that I must to do. I created a twig for admin which displays a list that take data from a table in the database. In each row of the list I created a button that I want to fix specific cell of the table. So each line has its own id.
See the image from page list:
I made the controller file but I stuck in model file that must do the rest work.
In the following code I have to change something so that by pressing the repair button it reads the specific id.
public function repairSaveCarts($link_id=" ") {
$this->db->query("SELECT * FROM " . DB_PREFIX . "save_cart WHERE link_id = '" . (int)$link_id . "'");
$db_id = $this->db->getLastId();
$end_url = base64_encode(serialize($db_id));
$url = $this->config->get('config_url').$end_url;
$this->db->query("UPDATE " . DB_PREFIX . "save_cart SET shorturl = '" . $this->db->escape($url) . "' WHERE link_id = '" . (int)$db_id . "'");
}
I thing that the change must be done in $db_id = $this->db->getLastId();
line but I'm not sure.
Someone that can help please.
And finally i make it. I replace this:
public function repairSaveCarts($link_id, $base) {
$end_url = base64_encode(serialize($link_id));
$url = $base.$end_url;
$this->db->query("UPDATE " . DB_PREFIX . "save_cart SET shorturl = '" . $this->db->escape($url) . "' WHERE link_id = '" . (int)$link_id . "'");
}
with this on model file:
public function repairSaveCarts($link_id) {
$end_url = base64_encode(serialize((int)$link_id));
if ($this->request->server['HTTPS']) {
$url = HTTPS_CATALOG . $end_url;
} else {
$url = HTTP_CATALOG . $end_url;
}
$this->db->query("UPDATE " . DB_PREFIX . "save_cart SET shorturl = '" . $this->db->escape($url) . "', date_added = NOW() WHERE link_id = '" . (int)$link_id . "'");
}
Thank you Daniel for your help.