Serialize函数在查询中不起作用

时间:2014-06-24 14:57:58

标签: php mysql serialization

您好我使用select语句更新查询。查询使用select语句更新我的表行(select语句返回多行)。查询工作正常,没有序列化功能。但现在我想将列中的文本分开并以正确的格式显示结果。为此,我使用了序列化函数,但我的查询现在没有运行。我只是希望将文本与列分开对我来说仍然没问题。因为我想在php中以正确的格式显示结果。谢谢。 这是我的代码:

如果(($ PARAM [ '新闻'])== 4){

$sql="UPDATE dashboard_widget_users SET configuration = ( SELECT GROUP_CONCAT(DISTINCT ad_news_texte.headline)
                FROM autodo.ad_news_texte
                INNER JOIN autodo.ad_news_oe ON ad_news_texte.news_id = ad_news_oe.id_ad_news
                INNER JOIN autodo.ad_news ON ad_news_oe.id_ad_news = ad_news.id
                WHERE ad_news.datum_archiv
                BETWEEN curdate( ) - INTERVAL DAYOFWEEK( curdate( ) ) +28
                DAY AND curdate( ) )
                WHERE dsnr_yw_user =12
                AND dsnr_dashboard_widget =2";  

}

    elseif(($param['news'])==6){

$sql="UPDATE dashboard_widget_users SET configuration = ( SELECT GROUP_CONCAT(DISTINCT ad_news_texte.headline)
                FROM autodo.ad_news_texte
                INNER JOIN autodo.ad_news_oe ON ad_news_texte.news_id = ad_news_oe.id_ad_news
                INNER JOIN autodo.ad_news ON ad_news_oe.id_ad_news = ad_news.id
                WHERE ad_news.datum_archiv
                BETWEEN curdate( ) - INTERVAL DAYOFWEEK( curdate( ) ) +42
                DAY AND curdate( ) )
                WHERE dsnr_yw_user =12
                AND dsnr_dashboard_widget =2";


    }
    elseif(($param['news'])==10){     
$sql="UPDATE dashboard_widget_users SET configuration=( SELECT GROUP_CONCAT(DISTINCT ad_news_texte.headline)
                FROM autodo.ad_news_texte
                INNER JOIN autodo.ad_news_oe ON ad_news_texte.news_id = ad_news_oe.id_ad_news
                INNER JOIN autodo.ad_news ON ad_news_oe.id_ad_news = ad_news.id
                WHERE ad_news.datum_archiv
                BETWEEN curdate( ) - INTERVAL DAYOFWEEK( curdate( ) ) +70
                DAY AND curdate( ) )
                WHERE dsnr_yw_user =12
                AND dsnr_dashboard_widget =2";


    }       
    $sql_select=mysql_query($sql) ;
    while ($row = mysql_fetch_array($sql_select)) {
    $config=serialize($row['configuration']);

     $update="UPDATE dashboard_widget_users w SET w.configuration=\"".mysql_real_escape_string(serialize($config))."\" WHERE w.dsnr_yw_user =12 AND w.dsnr_dashboard_widget=2 ";
     $update_news=mysql_query($update, $myConnection);
    }

没有序列化功能的更新查询结果。您可以使用select语句查看多行使用update语句存储在单行内。但现在我想在php中以正确的分隔格式回应上述结果。因此,我使用serialize函数将结果存储到数据库中,并使用unserialize函数以正确的格式获得结果:

Neu:Angebote nur noch mit Kundennamen druckbar!,新:仅提供客户名称打印!,AutoDo!更新:Neue Suchkriterien in der Fahrzeugsuche!,AutoDo!更新:车辆搜索中的新搜索条件! ,从TopUsed Navigator导出到Autoscout和Mascus,NUR OFFLINE AutoDo!更新:Neue Funktionen in derFahrzeugsuchefürIhreHomepage!,AutoDo!新闻:NeuePflichtfelderfürNeuwagenbei mobile.de !, Neues Suchkriterium:召回活动,新搜索标准:召回活动,AutoDo!新闻:NeuePflichtfelderfürNeuwagenbei AutoScout24.de !,交付给Schmitz Cargobull俄罗斯的新公司间价格。,AutoDo! startet durch。

0 个答案:

没有答案