我正在创建自定义CMS,因此我有一个数据库表应包含我所有的网站设置...示例(metakey => sitelogo,站点名称,电子邮件等)和另一列(元值=> logo.png,示例名称,martin@asd.com等)。
我已经完成了一个查询来从数据库表中读取某些数据,但是我不确定如何通过一个查询来读取所有数据,或者在一个查询中更新多个数据。
更正的代码:
<?php
$stmt0 = $conn->prepare("SELECT meta_value FROM settings WHERE meta_key IN ('site_name', 'login_logo', 'contact_email', 'instagram_token', 'instagram_photos', 'maintenance_mode', 'facebook_link', 'instagram_link', 'twitter_link', 'about_text', 'site_logo') ");
$stmt0->execute();
$stmt0->store_result();
$stmt0->bind_result($sitename, $login_logo, $email, $token, $photos, $maintenance, $facebook, $instagram, $twitter, $about, $sitelogo);
$stmt0->fetch();
echo $sitename;
?>
但是现在我有error_log ... PHP警告:mysqli_stmt :: bind_result():绑定变量的数量与准备好的语句中的字段数量不匹配
能否请您提供一些示例PHP代码如何进行?
答案 0 :(得分:1)
要读取所有数据:
Sub Test()
Dim IndustryArray() As Variant
Dim element As Variant
Dim Industry As Range
Dim Data As Variant
Dim ptITS As PivotTable
Dim pfITS As PivotField
Dim ppfITS As PivotField
Set ptITS = Worksheets("Industry Time Series").PivotTables("PivotTable1")
Set pfITS = ptITS.PivotFields("[All Industries Combined].[Industry Details].[Industry Details]")
Set ppfITS = ptITS.PageFields("[All Industries Combined].[Industry Details].[Industry Details]")
Set Industry = Worksheets("Industry List").Range("A2:A211")
ReDim IndustryArray(0 To Industry.Cells.Count + 1)
For i = 0 To Industry.Cells.Count + 1
IndustryArray(i) = "[ All Industries Combined].[Industry Details].&[" & Industry.Cells(i + 1).Value & "]"
Next i
For Each element In IndustryArray
pfITS.ClearAllFilters
pfITS.VisibleItemsList = element <-- error (for different variations as well)
Next element
End Sub
要读取多个值:
SELECT meta_key, meta_value FROM settings
您要解析的每个值有一个SELECT meta_key, meta_value FROM settings WHERE meta_key IN (?,?,?...)
,并且还有一个绑定。
请注意,使用像这样的变量查询时,PDO的使用要容易得多,因此,如果您对?
不太熟悉,则可能需要研究PDO可以如何提供帮助。