Добавить mysqli соединение внутри fuelphp - PullRequest
0 голосов
/ 03 января 2019

У меня есть 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

Ответы [ 2 ]

0 голосов
/ 21 февраля 2019

Вам нужно посмотреть, как вы используете пространства имен.

0 голосов
/ 03 января 2019

Вам просто нужно добавить "\" перед mysqli

...