Cakephp SQL 转储不显示查询
由于某种原因,我的 cakephp 应用程序没有显示对数据库进行的任何查询。它可以很好地打印表格,但没有记录。什么可能导致这种情况?
For some reason my cakephp application is not showing any of the queries made to the database. It prints the table fine, but there are not records. What could cause this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
检查以确保您正确提取记录。
然后,当您将它们添加到视图中时,请确保正确循环它们:
UPDATE
要显示 SQL 语句,请确保在 core.php 中进行了以下设置
另外,在布局中,请确保您已将某人包含在
和
标记之间:
Check to make sure you are pulling the records correctly.
Then when you add them in the view, be sure you are looping through them correctly:
UPDATE
To show the SQL statements, be sure you have the following set in core.php
Also, in the Layout, besure you have this included someone between the
<body>
and</body>
tags:我假设您得到一个空表,其中只有“Nr”、“Query”、“Error”等列标题?
您得到空表,因为您有“Configure::write('debug',0);”在“Configure::write('debug',2);”之前设置某处放。找到它的第一个实例并将其删除或将其更改为“2”。
我知道您早已解决了这个问题,但希望它将来对其他人有帮助。
I assume that you are getting an empty table with just the "Nr","Query","Error", etc. column headers?
You are getting the empty table because you have "Configure::write('debug',0);" set somewhere before you have "Configure::write('debug',2);" set. Find the first instance of it and delete it or change it to "2".
I know that you have long since fixed this problem but hopefully it helps somebody else in the future.
CakePHP 调试工具包可以帮助您。安装后,您会注意到 CakePHP 页面的右上角有一个小(饼图)图标。单击该按钮将允许您查看各种有用的信息,对于此问题最重要的是,页面加载时后端发生的所有 SQL 查询。
The CakePHP debug kit can help you. After you install it, you will notice a small (pie-chart) icon on the top right of your CakePHP pages. Clicking on that will allow you to see various useful information, and most importantly for this issue, all the SQL queries that occurred in the back-end upon the page loading.
我在 cakephp 中遇到了类似的问题。我发现 debug($variable) 对内容大小有限制。由于您正在从数据库中获取大量内容,因此无法打印。尝试改为执行 print_r($variable) 。要正确格式化它,你可以这样做
I faced a similar problem in cakephp. I found that debug($variable) has limitation to the content size. Since you are fetching huge sized content from database, it is not able to print. Try doing print_r($variable) instead. To format it properly, you can do like this