Php 含锂积垢;MySQL

Php 含锂积垢;MySQL,php,mysql,frameworks,lithium,Php,Mysql,Frameworks,Lithium,我刚刚开始使用PHP框架Limition(V0.10)。 我遵循了使用MongoDB作为数据库的方法。 为了进一步了解锂,我想将DBMS从MonogoDB切换到MySQL 我遇到的问题是,当我在浏览器中打开/posts/时,只会显示一个没有错误消息的空白页面。另外,当我转到/posts/add/时,会显示正确的表单,但在提交数据(正确写入数据库)后,Lili也只会显示一个空白页面。怎么了 另外,在阅读了Limition中关于模型的Limition文档之后,我仍然不太确定该模型的逻辑(在本例中)是

我刚刚开始使用PHP框架Limition(V0.10)。
我遵循了使用MongoDB作为数据库的方法。
为了进一步了解锂,我想将DBMS从MonogoDB切换到MySQL

我遇到的问题是,当我在浏览器中打开
/posts/
时,只会显示一个没有错误消息的空白页面。另外,当我转到
/posts/add/
时,会显示正确的表单,但在提交数据(正确写入数据库)后,Lili也只会显示一个空白页面。怎么了

另外,在阅读了Limition中关于模型的Limition文档之后,我仍然不太确定该模型的逻辑(在本例中)是什么

更新1:

看起来好像APC缓存有问题。在安装了APC并重命名了包含锂元素的文件夹后,应用程序正常运行。当保留包含锂的文件夹的名称不变时,我得到一个缓存错误:

Warning: include(/var/www/web/frameworks/lithium/app/resources/tmp/cache/templates/template_views_layouts_default.html_886_1308416958_798.php) [function.include]: failed to open stream: No such file or directory in /var/www/web/frameworks/lithium/libraries/lithium/template/view/adapter/File.php on line 111

Warning: include() [function.include]: Failed opening '/var/www/web/frameworks/lithium/app/resources/tmp/cache/templates/template_views_layouts_default.html_886_1308416958_798.php' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/web/frameworks/lithium/libraries/lithium/template/view/adapter/File.php on line 111
结束更新1

我手动设置了一个MySQL表
posts
,其中包含
id
title
body

/app/models
中的My
Posts.php
模型:

<?php
namespace app\models;

class Posts extends \lithium\data\Model {

}
?>
最后是
/app/views/posts/
中的我的视图
index.html.php

<?php foreach($posts as $post): ?>
<article>
    <h1><?=$post->title ?></h1>
    <p><?=$post->body ?></p>
</article>
<?php endforeach; ?>
<?=$this->form->create(); ?>
    <?=$this->form->field('title');?>
    <?=$this->form->field('body', array('type' => 'textarea'));?>
    <?=$this->form->submit('Add Post'); ?>
<?=$this->form->end(); ?>

<?php if ($success): ?>
    <p>Post Successfully Saved</p>
<?php endif; ?>
一些提示

1) 你确定锂电池总体运行正常吗?我不明白你真正的问题是什么

2) 无需更改PostsController,
Posts::all()
只是
Posts::find('all')的简写

3) 您可能需要更改帖子的模型,Limition(使用MySQL)希望表中有一个id列用作键,如果您没有名为id的冒号,则可能需要在模型中添加一个冒号

例如,如果您有一个表,其中的列有postidtitlebodydate。。。将此添加到您的模型中

<?php
 namespace app\models;

 class Posts extends \lithium\data\Model { 
   public $_meta = array('key' => 'postid');        
 }

?>
查看《锂手册》以获取更多帮助:

型号

控制器

视图

一些提示

1) 你确定锂电池总体运行正常吗?我不明白你真正的问题是什么

2) 无需更改PostsController,
Posts::all()
只是
Posts::find('all')的简写

3) 您可能需要更改帖子的模型,Limition(使用MySQL)希望表中有一个id列用作键,如果您没有名为id的冒号,则可能需要在模型中添加一个冒号

例如,如果您有一个表,其中的列有postidtitlebodydate。。。将此添加到您的模型中

<?php
 namespace app\models;

 class Posts extends \lithium\data\Model { 
   public $_meta = array('key' => 'postid');        
 }

?>
查看《锂手册》以获取更多帮助:

型号

控制器

视图


你会收到或根本不会收到什么错误,尝试var_dump($posts)?@jurka:一点也不。Chrome只显示一个错误页面,错误324(net::ERR\u EMPTY\u RESPONSE):服务器关闭了连接。服务器未发送任何数据。
您收到或根本没有收到什么错误,请尝试var_dump($posts)?@jurka:根本没有。Chrome只显示一个错误页面,错误324(net::ERR\u EMPTY\u RESPONSE):服务器关闭了连接。服务器未发送任何数据。
感谢您的详细回答!我阅读了模型、控制器和视图的文档,并相应地更新了我的问题。我仍然不太确定出了什么问题。可能是缓存问题吗?因为我觉得Limition不会马上得到我对文件所做的更改。我要做的第一件事是使用.10而不是旧的0.9.9。。。几乎所有的设置都是一样的(你可以复制你的控制器/模型/视图),但是它是更新的代码。我将Limition更新为0.10,并相应地更新了我的问题(参见答案的更新部分)。问题解决了,看来问题是因为没有安装APC。谢谢你的详细回答!我阅读了模型、控制器和视图的文档,并相应地更新了我的问题。我仍然不太确定出了什么问题。可能是缓存问题吗?因为我觉得Limition不会马上得到我对文件所做的更改。我要做的第一件事是使用.10而不是旧的0.9.9。。。几乎所有的设置都是一样的(你可以复制你的控制器/模型/视图),但是它是更新的代码。我将Limition更新为0.10,并相应地更新了我的问题(参见答案的更新部分)。问题解决了,看起来问题是因为没有安装APC。
public function locations($companyid,$state=null) {

 /* removes null or false values with array_filter() */
 $conditions = array_filter(array('companyid' => $companyid, 'state' => $state));

 /* pass $conditions array to the Locations model, find all, order by city */
 $locations = Locations::find('all', array( 
       'conditions' => $conditions,
       'order' => array('city' => 'ASC')
 ));

 return compact('locations');

}