0

我有一个关于 php 和 sql 的问题。在数据库中,我有一个商店表“x”,其中有一个标签列,其中包含混合标签,使用运算符“like”从中过滤产品的集合。我必须将过滤后的集合与商店第 1 列中的集合进行比较。如果这两个集合相等,那么我可以从第 2 列的商店表中检索适当的值并将其输入到 csv 文件中。在 php 中,我从“x”商店下载了带有标签的列,但我不知道如何添加到我通过查询搜索的类别并将其与商店“s”列中的数据进行比较。我试图用explode()从foreach循环中分解生成的字符串,以从列中的每个单元格中获取一个数组,但得到了从数据库中获取的原始数组。我也尝试了一个常规的 for 循环,但它也失败了。如何从标签列中获取这个值并将其与另一列中的数据进行比较?

public static function findEmpikCategory()
{
$empik_lilante_categories = MysqlProvider::getEmpikCategory();       // empik and lilante categories from empik_categories in which the 'collection' is included
// get a specific category (lilante_category) from empik_categories
foreach($empik_lilante_categories as $categories)
{
$lilante_category_from_empik[] = $categories['lilante_category'];
}

return $lilante_category_from_empik;
}
//$lilante_category = explode(",", $lilante_category_for_offers_products, 0);

// searching lilante categories from the shopifyProductsLilante array


public static function findLilanteCategory()
{
$empik_cateries_equals_lilante_categories = MysqlProvider::getEmpikCategoryEqualLilanteCategory();      // empik categories corresponding to lilante categories

$lilante_category_to_check = CSVFileGenerator::findEmpikCategory();
            $lilante_category_for_offers_products = MysqlProvider::getLilanteCategoryByOffersEmpik();       // lilante categories for all empik products

//print_r($lilante_category_to_check);

foreach($lilante_category_for_offers_products as $lilanteCategories)
{ 

  foreach($lilanteCategories as $lilanteCategory)
  {
     echo "<br/>";
     //print_r($lilanteCategory);
     echo "<br/>";
     print_r(explode(",", $lilanteCategory, 0));
     //echo "<br/>";
     // echo gettype($lilanteCategory) . "<br>";        // each element is a string
     // print_r($lilanteCategory);                 
    }
   }

foreach($lilante_category_to_check as $lilanteCategoryFromEmpik)
{
  echo "<br/>";
  print_r($lilanteCategoryFromEmpik);
  echo "<br/>";
}
  //fclose($file_open);
            
return ;
}
4

0 回答 0