简体   繁体   English

在Yii控制器中

[英]In Yii controller

I'm newbie and learning Yii framework where Im designing first small application and got stuck on this position where I need your attention as your guys are guru. 我是新手,正在学习Yii框架,在该框架中,我设计了第一个小型应用程序,并被困在这个位置,在这里我需要您的关注,因为你们是专家。

I have a 'City name' list on main layout in header section where a user select a 'City' then I would like to pass that City_id to 'PostController' and search for that city post and display the last Postonly. 我在标题部分的主布局上有一个“城市名称”列表,用户在其中选择一个“城市”,然后我想将该City_id传递给“ PostController”,然后搜索该城市帖子并显示最后一个Postonly。

Any idea how to handle this. 任何想法如何处理。

I look forward to hear from you guys soon and will appreciated an early reply. 我希望很快能收到您的来信,希望您早日得到答复。

Khan 可汗

You can use a standard to pass the selected city value to your PostCtonroller, you can then have your PostController call a function within one of your models to run whatever search you need on your database layer. 您可以使用标准将选定的城市值传递到PostCtonroller,然后可以让PostController在模型之一中调用一个函数,以在数据库层上运行所需的任何搜索。 You then take those results, pass them back to the controller and render a new page with your result. 然后,您将获得这些结果,并将其传递回控制器,并使用结果呈现新页面。 You can also do everything with Ajax so its nice and dynamic, but if you're new it would be best to use the basics first. 您还可以使用Ajax进行所有操作,使其美观而又动态,但是,如果您是新手,最好先使用基础知识。

Also check out the yii framework website as they have a screencast (Video) about using their built in CRUD features. 还可以访问yii framework网站,因为他们有关于使用其内置CRUD功能的截屏视频(视频)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM