我在我的数据库中创建了一个名为ccc_campaigns的表,我正在使用以下语句检索数据:
global $wpdb;
$campaign_list = $wpdb->get_results(
'SELECT *
FROM ccc_campaigns
ORDER BY id DESC');
这在我的本地和我的一台服务器上按预期工作,数据显示为:
foreach ($campaign_list as $campaign)
但是在应该使用此wordpress的服务器中,查询将返回空白。我无法理解或找不到该服务器失败的原因。
有什么想法吗?
非常感谢
答案 0 :(得分:0)
确保数据库前缀相同。
编辑:我猜你正在构建某种插件,所以为了确保db前缀不会导致任何错误,请使用此函数。
import math
import maya.cmds as cmds
import maya.OpenMaya as OpenMaya
import maya.OpenMayaUI as OpenMayaUI
# Get active view.
view = OpenMayaUI.M3dView.active3dView()
# Get camera MFnDagPath.
dagCam = OpenMaya.MDagPath()
view.getCamera(dagCam)
# Build MFnCamera.
fnCam = OpenMaya.MFnCamera(dagCam)
# Get post matrix.
postMatrix = fnCam.postProjectionMatrix()
# Get current film roll value to calculate roll.
filmRollValue = cmds.getAttr("%s.filmRollValue" % dagCam.fullPathName())
deviceAspect = cmds.getAttr("defaultResolution.deviceAspectRatio")
# This is how rotation is calculate (Where does pivot come in?)
cz = math.cos(math.radians(filmRollValue))
sz = math.sin(math.radians(filmRollValue))
# Build matrix.
matList = [0.0] * 16
matList[0] = cz
matList[1] = -sz * deviceAspect
matList[2] = 0.0
matList[3] = 0.0
matList[4] = sz / deviceAspect
matList[5] = cz
matList[6] = 0.0
matList[7] = 0.0
matList[8] = 0.0
matList[9] = 0.0
matList[10] = 1.0
matList[11] = 0.0
matList[12] = 0.0
matList[13] = 0.0
matList[14] = 0.0
matList[15] = 1.0
# Create MMatrix.
rollMMatrix = OpenMaya.MMatrix()
OpenMaya.MScriptUtil().createMatrixFromList(matList, rollMMatrix)
# Print values.
print("\nMy Film Roll:")
for x in xrange(0, 4):
print(round(rollMMatrix(x, 0), 3),
round(rollMMatrix(x, 1), 3),
round(rollMMatrix(x, 2), 3),
round(rollMMatrix(x, 3), 3))
print("\nPost Matrix from Maya:")
for x in xrange(0, 4):
print(round(postMatrix(x, 0), 3),
round(postMatrix(x, 1), 3),
round(postMatrix(x, 2), 3),
round(postMatrix(x, 3), 3))