在meta_query中设置比较错误 - wordpress

时间:2015-08-14 14:39:04

标签: php wordpress

db!中保存的复选框

db结构(wp_postmeta table)

Process{
 $strComputerName = (Get-WmiObject -Class Win32_ComputerSystem | Select-Object Name).Name
 $strComputerModel = (Get-WmiObject -Class Win32_ComputerSystem | Select-Object Model).Model
 $strSerialNumber = (Get-WmiObject -Class Win32_BIOS | Select-Object SerialNumber).SerialNumber
 $strDate = Get-Date
 $erroractionpreference = "SilentlyContinue"
 $strSMTP = $server
 $strSubject = $subject
 $strBody = "Hostname: $strComputerName Model: $strComputerModel Serial: $strSerialNumber Date: $strDate"
 $MailMessage = New-Object System.Net.Mail.MailMessage
 $MailMessage.IsBodyHtml = $true
 $SMTPClient = New-Object System.Net.Mail.smtpClient
 $SMTPClient.host = $strSMTP
 $Sender = New-Object System.Net.Mail.MailAddress($from, "ConfigMgr")
 $Recipient = New-Object System.Net.Mail.MailAddress($to)
 $MailMessage.Sender = $Sender
 $MailMessage.From = $Sender
 $MailMessage.Subject = $strSubject
 $MailMessage.To.add($Recipient)
 $MailMessage.Body = $strBody
 $SMTPClient.Send($MailMessage)
}

已选择两个复选框!

我想查找________________________________________________________________ | | | | meta_key | meta_value | |_______________|_______________________________________________| | | | | artist_nameaa | a:2:{i:51;s:2:"51";i:60;s:2:"60";} | |_______________|_______________________________________________| 数组中有artist_nameaa个键的帖子

  

51 就是一个例子

这是我的尝试:

51

1 个答案:

答案 0 :(得分:1)

...比较运算符用于替换多个where子句(docs)。它最终会查找完全匹配的结果。

您正在做的更多是搜索。您不知道序列化字符串中的数据集将落在何处。对于此类搜索,您应使用IN()运算符(docs)。您需要使用通配符标记进行此类搜索。

从我收集的有关您存储的数据类型的内容中,您可能需要重新考虑您的存储机制。自定义字段确实支持同一元键的多个值,这将是一种快速方法。您还可以利用Custom Post Types或自定义表格(wpdb)。