将项目从PC迁移到其他PC后,错误在codeigniter中不推荐使用each()函数[重复]
Posted
技术标签:
【中文标题】将项目从PC迁移到其他PC后,错误在codeigniter中不推荐使用each()函数[重复]【英文标题】:Error The each() function is deprecated in codeigniter, after migrate project from PC to other PC [duplicate] 【发布时间】:2018-09-29 06:20:21 【问题描述】:我将一个项目从一台 PC 复制到另一台 PC。当我提交表单时,我收到一个错误。这个项目在我的第一台电脑上运行良好,但我不知道如何解决,我搜索了太多,我发现主题说问题出在 php 版本中,但我仍然不知道如何解决。另外,如果这是我的问题,这是我的错误:
消息:each() 函数已弃用。此消息将 禁止进一步调用
文件名:core/Security.php
行号:357
回溯:
文件:C:\xampp\htdocs\Elvan\application\models\Out_m.php 行:82 功能:发帖
文件:C:\xampp\htdocs\Elvan\application\controllers\Order.php 行:36 功能:发送
文件:C:\xampp\htdocs\Elvan\index.php 行:315 函数:require_once
这是我的模型
function send()
date_default_timezone_set('Africa/Cairo');
//////////////////////////////////////////////////////////////////
// to get user id
$session_data = $this->session->userdata('logged_in');
$name = $session_data['username'];
$this->db->select('u_id,u_name,u_username,u_company_id');
$this->db->from('users');
$this->db->where('u_username', $name);
$user_data = $query = $this->db->get();
if ($user_data->num_rows() > 0)
foreach ($query->result_array() as $row_userdata)
$mydata[] = $row_userdata;
$user_id = $mydata[0]['u_id'];
$user_name = $mydata[0]['u_name'];
$usercompanyid=$mydata[0]['u_company_id'];
///////////////////////////////////////////////////////////////////
// to get product name based on product id - this un used i can delete this anytime .
$this->db->select('p_name,p_qty');
$this->db->from('products');
$this->db->where('p_id', $this->input->post('p_id_select'));
$query = $this->db->get();
if ($query->num_rows() > 0)
foreach ($query->result_array() as $row)
$data[] = $row;
$post = $this->input->post();
////////////////////////////////////////////////////////////////////////
// get the Customer name to sava it into invoice table
$this->db->select('*');
$this->db->from('customers');
$this->db->where('c_company_id',$usercompanyid);
$this->db->where('c_id',$this->input->post('customer_name'));
$query=$this->db->get();
if ($query->num_rows() > 0)
foreach ($query->result_array() as $row_custdata)
$mycust[] = $row_custdata;
$customer_n = $mycust[0]['c_name'];
// Select the payment term from database
$this->db->select('*');
$this->db->from('payment_method');
$this->db->where('p_company_id',$usercompanyid);
$this->db->where('p_id',$this->input->post('payment_term'));
$query=$this->db->get();
if ($query->num_rows() > 0)
foreach ($query->result_array() as $row_custdata)
$payment[] = $row_custdata;
$paymnet_name=$payment[0]['p_name'];
// check if the invoice details if already exist or not . . . . .
$this->db->select('*');
$this->db->from('invoices');
$this->db->where('i_company_id',$usercompanyid);
$this->db->where('i_number',$this->input->post('invoice_number'));
$this->db->where('i_customer_id',$this->input->post('customer_name'));
$query=$this->db->get();
if($query->num_rows()==0)
$invoice_data=array(
'i_number'=>$this->input->post('invoice_number'),
'i_customer_id'=>$this->input->post('customer_name'),
'i_payment'=>$this->input->post('payment_term'),
'i_payment_name'=>$paymnet_name,
'i_u_id'=>$user_id,
'i_u_name'=>$name,
'i_company_id'=>$usercompanyid,
'i_date'=>date('Y-m-d H:i:s'),
'i_branch'=>$this->input->post('branch'),
'i_customer_name'=>$customer_n
);
$this->db->insert('invoices',$invoice_data);
////////////////////////////////////////////////////////////////////////////
// check Qty for all products
for ($i = 0; $i < count($post['select_product']); $i++)
$this->db->select('*');
$this->db->from('stock');
$this->db->where('s_p_id',$post['select_product'][$i]);
$query=$this->db->get();
if ($query->num_rows() > 0)
foreach ($query->result_array() as $row)
$stockdata[]=$row;
if ($stockdata[$i]['s_p_qty']<$post['qty'][$i])
$this->session->set_flashdata('error',' Please check your stock quantities');
redirect('Order', 'refresh');
die();
//////////////////////////////////////////////////////////////////////////
// loop area
$post = $this->input->post();
for ($i = 0; $i < count($post['select_product']); $i++)
$this->db->select('c_name');
$this->db->from('customers');
$this->db->where('c_id',$post['customer_name']);
$query=$this->db->get();
if ($query->num_rows() > 0)
foreach ($query->result_array() as $row)
$customer[]=$row;
$session_data = $this->session->userdata('logged_in');
$name = $session_data['username'];
$this->db->select('u_money');
$this->db->from('users');
$this->db->where('u_username', $name);
$user_data = $query = $this->db->get();
if ($user_data->num_rows() > 0)
foreach ($query->result_array() as $row_userdata)
$mymoney[] = $row_userdata;
$user_money=$mymoney[$i]['u_money'];
$this->db->select('p_price,p_name,p_tax');
$this->db->from('products');
$this->db->where('p_id',$post['select_product'][$i]);
$query=$this->db->get();
if ($query->num_rows() > 0)
foreach ($query->result_array() as $row)
$productdata[]=$row;
$this->db->select('*');
$this->db->from('stock');
$this->db->where('s_p_id',$post['select_product'][$i]);
$query=$this->db->get();
if ($query->num_rows() > 0)
foreach ($query->result_array() as $row)
$stockdata1[]=$row;
if ($post['qty'][$i] <=0 || $post['price'][$i]<=0 ||$post['total'][$i]!=$post['qty'][$i] * $post['price'][$i] )
die();
else
if ($stockdata1[$i]['s_p_qty']>=$post['qty'][$i])
$priceandtax=$productdata[$i]['p_price']+$productdata[$i]['p_tax'];
$data1 = array(
't_customer_id' => $post['customer_name'],
't_customer_name'=>$customer[$i]['c_name'],
't_order_number' => $post['invoice_number'],
't_branch' => $post['branch'],
't_p_name'=>$productdata[$i]['p_name'],
'payment' => $post['payment_term'],
't_p_id' => $post['select_product'][$i],
'payment_name'=>$paymnet_name,
't_qty' => $post['qty'][$i],
't_p_price' => $productdata[$i]['p_price'],
't_p_tax'=>$productdata[$i]['p_tax']*$post['qty'][$i],
't_p_total_price' =>$productdata[$i]['p_price']*$post['qty'][$i],
't_u_id'=>$user_id,
't_u_name'=>$user_name,
't_date'=>date('Y-m-d H:i:s'),
't_company_id'=>$usercompanyid
);
$this->db->insert('transactions', $data1);
$new_qty=$stockdata1[$i]['s_p_qty']-$post['qty'][$i];
$stock=array('s_p_qty'=>$new_qty);
$this->db->where('s_p_id',$post['select_product'][$i]);
$this->db->where('s_company_id',$usercompanyid);
$this->db->update('stock',$stock);
$total_money=$priceandtax*$post['qty'][$i];
$mny_up=array('u_money'=>$total_money+$user_money);
$this->db->where('u_id',$user_id);
$this->db->update('users',$mny_up);
$this->db->set('i_total', 'i_total + ' . $total_money, FALSE);
$this->db->set('i_sub_total', 'i_sub_total + ' .$productdata[$i]['p_price']*$post['qty'][$i], FALSE);
$this->db->set('i_tax', 'i_tax + ' . $productdata[$i]['p_tax']*$post['qty'][$i], FALSE);
$this->db->where('i_company_id',$usercompanyid);
$this->db->where('i_number',$post['invoice_number']);
$this->db->where('i_customer_id',$this->input->post('customer_name'));
$this->db->update('invoices');
【问题讨论】:
不是 CodeIgniter 弃用了each()
函数,而是 PHP - php.net/manual/en/function.each.php - 所以降级 PHP 的版本,或者重写代码以避免使用该函数
【参考方案1】:
沉默的操作员 = 吊死自己的绳子。
- while (list($key, $val) = each($list))
+ foreach ($list as $key => $val)
【讨论】:
以上是关于将项目从PC迁移到其他PC后,错误在codeigniter中不推荐使用each()函数[重复]的主要内容,如果未能解决你的问题,请参考以下文章
将旧项目从 C++Builder 10.2 迁移到 10.2.3 在运行时崩溃
PC迁移与管理上海道宁为每个用户和每个 PC 传输和迁移场景提供解决方案——PCmover
将 android 项目从 pc 移动到另一个,Firebase Auth 问题? [复制]