gpt4 book ai didi

php - 我如何才能只选择 drupal 看门狗数据库表中的变量类型?

转载 作者:搜寻专家 更新时间:2023-10-30 20:27:00 27 4
gpt4 key购买 nike

*****~PLZ HELP~***我想对变量进行特殊化并采用类型,例如'Notice','Error'..在接下来的代码中执行类似这样的事情

3710 a:6:{s:5:"%type";s:6:"Notice";s:8:"!message";s:24:"Undefined variable: path";s:9: "%function";s:3:"l()";s:5:"%file";s:44:"c";s:5:"%line";i:2469;s:14:"severity_level";i:5;}

3711 a:6:{s:5:"%type";s:6:"Notice";s:8:"!message";s:24:"Undefined variable: path";s:9: "%function";s:3:"l()";s:5:"%file";s:44:"/c";s:5:"%line";i:2511;s:14: "severity_level";i:5;

3712 a:6:{s:5:"%type";s:7:"Warning";s:8:"!message";s:141:"l() 缺少参数 2,已调用在第 171 行并定义了";s:9:"%function";s:3:"l()";s:5:"%file";s:44:"";s:5:"%line";i:2458;s:14:"severity_level";i:4;

3713 a:6:{s:5:"%type";s:6:"Notice";s:8:"!message";s:24:"Undefined variable: path";s:9: "%function";s:3:"l()";s:5:"%file";s:44:"";s:5:"%line";i:2469;s:14:"severity_level ";i:5;}**

    function blabla_page() {

// Begin building

the query.
$query = db_select('watchdog', 'th')
->extend('PagerDefault')
->orderBy('wid')
->fields('th')
->limit(10);

// Fetch the result set.
$result = $query->execute();

// Loop through each item and add to the $rows array.
foreach ($result as $row) {
$rows[] = array(
$row -> wid,
$row -> variables,
);
}
// Headers for theme_table().
$header = array('ID', 'Message');

// Format output.
$output = theme('table', array('header' => $header, 'rows' => $rows)). theme('pager');
return $output;
}

最佳答案

字段中的信息是序列化的,应该这样做。

  foreach ($result as $row) {
$message1=unserialize($row->variables);
if($message1['%type']){
$rows[] = array(
$row -> wid,
$message1['%type'],
);
}
}

现在只有当 %type 项存在时,输出才会被添加到行数组

关于php - 我如何才能只选择 drupal 看门狗数据库表中的变量类型?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28473961/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com