如何 post 在 opencart 中从数据库中形成和获取数据
how to post form and get data from database in opencart
如何 post 形成 posted 数据到控制器,我不知道如何在获取后将 posted 变量从控制器传递到模型 我想传递视图的变量
controller.php
if(isset($_POST["email"]))
{
$email=$_POST["email"];
}
$this->load->model('order/myorder');
$data['data1']=$this->model_order_myorder->getOrder($email) ;
view.php
foreach ($data1 as $row)
{
echo echo $row->order_id;
}
model.php
<?php
class ModelOrderMyorder extends Model {
public function getOrder($email) {
$sql = "SELECT * FROM ".DB_PREFIX."order,".DB_PREFIX."order_product WHERE ".DB_PREFIX."order.email='$email'";
$query = $this->db->query($sql);
return $query ;
}
}
问候
开发
您只需将值作为参数传递,例如
$this->model_shipping_order->getordertracking($_POST['email']) {
您还应该转义查询中的参数以防止 SQL 注入,例如
WHERE email = '" . $this->db->escape($email) . "' ");
如何 post 形成 posted 数据到控制器,我不知道如何在获取后将 posted 变量从控制器传递到模型 我想传递视图的变量
controller.php
if(isset($_POST["email"]))
{
$email=$_POST["email"];
}
$this->load->model('order/myorder');
$data['data1']=$this->model_order_myorder->getOrder($email) ;
view.php
foreach ($data1 as $row)
{
echo echo $row->order_id;
}
model.php
<?php
class ModelOrderMyorder extends Model {
public function getOrder($email) {
$sql = "SELECT * FROM ".DB_PREFIX."order,".DB_PREFIX."order_product WHERE ".DB_PREFIX."order.email='$email'";
$query = $this->db->query($sql);
return $query ;
}
}
问候 开发
您只需将值作为参数传递,例如
$this->model_shipping_order->getordertracking($_POST['email']) {
您还应该转义查询中的参数以防止 SQL 注入,例如
WHERE email = '" . $this->db->escape($email) . "' ");