在fuelphp中添加mysqli连接

问题描述 投票:0回答:2

我有一个每周四发射的cron,但是我想在cron中添加一些其他行但是因为我使用FuelPhp,我不能这样做,因为图像中附加了错误。有没有办法可以像下面这样查询:

  $getAllDiscounts = "select * from discount_order where order_id = '{$order->id}' and user_add != '1'";
      $ResultgetAllDiscounts = mysqli_query($conn, $getAllDiscounts);
      $countDiscount = 1;
      if(mysqli_num_rows($ResultgetAllDiscounts) > 1)
      {
          while($RowgetAllDiscounts = mysqli_fetch_assoc($ResultgetAllDiscounts))
          {
              if($RowgetAllDiscounts['discount_code_id'] == $order->discount_code_id)
              {
                  //empty
              }
              else{
                  $get_Othername = "select * from discount_codes where id = '{$RowgetAllDiscounts['discount_code_id']}'";
                  $result_Othername = mysqli_query($conn, $get_Othername);
                  $row_Othername = mysqli_fetch_assoc($result_Othername);
                  $Othercode_name = "Discount Code: ".ucwords($row_Othername['code']);
                  $otherType = $row_Othername['discount_type'];
                  //get discount

                  if($otherType == '1' || $otherType == '2' || $otherType == '5')
                  {

                      if($otherType == '2')
                      {
                          $otherDiscount = $order->subtotal * $row_Othername['discount'];

                      }
                      elseif($otherType == '5')
                      {
                          $Othercode_name = "Free Item!";
                          $discountSku = $row_Othername['sku_id'];
                          $q_getSkuAmount = "select price from meal_options where id = '{$discountSku}'";
                          $r_getSkuAmount = mysqli_query($conn,$q_getSkuAmount);
                          $row_getSkuAmount = mysqli_fetch_assoc($r_getSkuAmount);
                          $otherDiscount = $row_getSkuAmount['price']/100;
                      }
                      else{
                          $otherDiscount = $row_Othername['discount']/100;
                      }
                      $otherDiscount = number_format($otherDiscount,2);

                  }

                  $inBalance .= '<tr style="font-family:lora,georgia,times new roman,serif">
                                 <td style="text-align: center;" width="15%">&nbsp;</td>
                                 <td width="65%">'.$Othercode_name.'</td>
                                 <td style="text-align: left; white-space: nowrap;" width="20%">-$'.$otherDiscount.'</td>
                                 </tr>';

              }
              $countDiscount++;
          }

      }

因为我已经准备好了这种格式的所有代码。但$ conn不起作用。有没有办法解决它而不必通过fuelPhp编码?enter image description here

php fuelphp
2个回答
0
投票

你只需要在mysqli之前添加一个“\”


0
投票

您需要查看您对命名空间的使用。

© www.soinside.com 2019 - 2024. All rights reserved.