问题描述
我抽出时间来试验 opencart 的扩展,但我卡住了。
$cart_options = base64_encode(serialize($cart_products));
$this->db->query("INSERT INTO `". DB_PREFIX ."save_cart`(`options`,`coupon`) VALUES ('$cart_options','$coupon')");
$db_id = $this->db->getLastId();
$end_url = base64_encode(serialize($db_id));
$url = $this->config->get('config_url').$end_url;
$json = array(
'text_copy'=> $text_copy,'url'=> $url,);
$this->response->addHeader('Content-Type: application/json');
$this->response->setoutput(json_encode($json));
我在表中添加了一个名称为“shorturl”的列,我希望在创建 &url 后将 url 复制到同一行中的表中。 有什么想法吗?
谢谢。
解决方法
您可以在生成 url 后通过在 url 生成下方添加查询来更新该行
$url = $this->config->get('config_url').$end_url;
$this->db->query("UPDATE ". DB_PREFIX ."save_cart
SET shorturl = '".$this->db->escape($url)."' WHERE id 或任何主键 = '“ .(int)$db_id.”'");