search
HomeBackend DevelopmentPHP TutorialopenPNE常用方法分享_PHP

复制代码 代码如下:
'asdfgasgsad'));?>这句话意思是包含'_sidemenu.php'并往其页面传一系列参数,'_sidemenu.php'页即可直接使用$form变量中的值
op_include_box('vote_question_create_box','asdfasdf',array('title'=>'创建问题','moreInfo'=>array('创建问题',link_to('创建问题2','@my_index'))));
?>
op_include_box('vote_question_create_box',get_slot('pager'),array('title'=>'创建问题','moreInfo'=>array('创建问题',link_to('创建问题2','@my_index'))));
?>
'vote_question_create_box'只是一个标记,'asdfasdf'或 get_slot('pager')则是要输出到页面上标题下的信息(这个方法里要包含slot只能用get_slot()不能用include_slot(),
而在页面中要包含slot则必须使用include_slot())
第三个数组参数中的键值名称title是固定的,是该段'vote_question_create_box'显示的标题,后面的'moreInfo'键名也是固定键值对应的数组则是罗列显示的内容列表

设定一个slot段落


包含指定的slot段落,设定的slot段落必须通过包含才能在页面上显示

op_include_form('vote_question_from',$form,array('title'=>'编辑问题','url'=>url_for('@vote_update?id='.$form->getObject()->getId()),));
?>包含一个表单对象,'vote_question_from'为标识名,$form为对应动作传来的表单对象,第三个数组参数title键值也url键值是固定的,分别对应显示的标题名和表单提交路径
对应动作内容为
public function executeEdit(sfWebRequest $request){
$object = $this->getRoute()->getObject();
//如果不是作者屏幕上显示404
$this->forward404Unless($this->getUser()->getMemberId() == $object->getMemberId());//$object->getMemberId()为传递过来的id值对应的那条记录的member_id字段值
$this->form = new VoteQuestionForm($object);
//访问此动作路径http://localhost/openpne/web/vote/edit/1
}
?>

用于分页时前后翻页的超链接
$pager来自动作里的 $this->pager = Doctrine::getTable('VoteQuestion')->getListPager($request->getParameter('page'));
PluginVoteQuestionTable类getListPager()方法里的内容↓
class PluginVoteQuestionTable extends Doctrine_Table
{
public function getListPager($page = 1,$size = 20)
{
$query = $this->createQuery()->orderBy('updated_at DESC');
$pager = new sfDoctrinePager('VoteQuestion',$size);//创建一个某表的分页对象,并传一个每页显示多少记录值
$pager->setQuery($query);//传一个查询语句对象
$pager->setPage($page);//设返回显示的页数
$pager->init();
return $pager;
}
}
?>
对应前台页面对分页结果集的沥遍
getResults() as $item): //利用openPNE分页机制获取指定分页结果集并沥遍每一条记录?>

getUpdatedAt(),'f') //'f'代表一种显示格式?>

getTitle(),count($item->getVoteAnswers())),'@vote_show?id='.$item->getId()) ?>




getId()) ?>相当于sdsfg
表名是驼峰模式在数据库里以下划线表示,字段名也是如此

链接的
就算不用方法也可以直接在action="此可直接写web/后的====模块名/动作名====或路由中设定好的web后的路径"

动作里的
$this->tasksObject = $this->getRoute()->getObject();
$this->getRoute()->getObject();//获取传过来的id参数值对应的表中的那条信息对象可通过get+字段名()获取字段值,如在页面中$tasksObject-getId();
至于如何确定获取的是哪个表则是通过路由类设置该动作路由时确定的,如下例确定的是vote_question表

class opVotePluginFrontendRouteCollection extends sfRouteCollection
{
public function __construct(array $options)
{
parent::__construct($options);
$this->routes = array(
'vote_edit' => new sfDoctrineRoute(
'/vote/edit/:id',
array('module' => 'vote', 'action' => 'edit'),
array('id' => '\d+', 'sf_method' => array('get')),
array('model' => 'VoteQuestion', 'type' => 'object')
),
);
}
}
?>
Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Working with Flash Session Data in LaravelWorking with Flash Session Data in LaravelMar 12, 2025 pm 05:08 PM

Laravel simplifies handling temporary session data using its intuitive flash methods. This is perfect for displaying brief messages, alerts, or notifications within your application. Data persists only for the subsequent request by default: $request-

cURL in PHP: How to Use the PHP cURL Extension in REST APIscURL in PHP: How to Use the PHP cURL Extension in REST APIsMar 14, 2025 am 11:42 AM

The PHP Client URL (cURL) extension is a powerful tool for developers, enabling seamless interaction with remote servers and REST APIs. By leveraging libcurl, a well-respected multi-protocol file transfer library, PHP cURL facilitates efficient execution of various network protocols, including HTTP, HTTPS, and FTP. This extension offers granular control over HTTP requests, supports multiple concurrent operations, and provides built-in security features.

Simplified HTTP Response Mocking in Laravel TestsSimplified HTTP Response Mocking in Laravel TestsMar 12, 2025 pm 05:09 PM

Laravel provides concise HTTP response simulation syntax, simplifying HTTP interaction testing. This approach significantly reduces code redundancy while making your test simulation more intuitive. The basic implementation provides a variety of response type shortcuts: use Illuminate\Support\Facades\Http; Http::fake([ 'google.com' => 'Hello World', 'github.com' => ['foo' => 'bar'], 'forge.laravel.com' =>

12 Best PHP Chat Scripts on CodeCanyon12 Best PHP Chat Scripts on CodeCanyonMar 13, 2025 pm 12:08 PM

Do you want to provide real-time, instant solutions to your customers' most pressing problems? Live chat lets you have real-time conversations with customers and resolve their problems instantly. It allows you to provide faster service to your custom

How to Register and Use Laravel Service ProvidersHow to Register and Use Laravel Service ProvidersMar 07, 2025 am 01:18 AM

Laravel's service container and service providers are fundamental to its architecture. This article explores service containers, details service provider creation, registration, and demonstrates practical usage with examples. We'll begin with an ove

Explain the concept of late static binding in PHP.Explain the concept of late static binding in PHP.Mar 21, 2025 pm 01:33 PM

Article discusses late static binding (LSB) in PHP, introduced in PHP 5.3, allowing runtime resolution of static method calls for more flexible inheritance.Main issue: LSB vs. traditional polymorphism; LSB's practical applications and potential perfo

PHP Logging: Best Practices for PHP Log AnalysisPHP Logging: Best Practices for PHP Log AnalysisMar 10, 2025 pm 02:32 PM

PHP logging is essential for monitoring and debugging web applications, as well as capturing critical events, errors, and runtime behavior. It provides valuable insights into system performance, helps identify issues, and supports faster troubleshoot

Customizing/Extending Frameworks: How to add custom functionality.Customizing/Extending Frameworks: How to add custom functionality.Mar 28, 2025 pm 05:12 PM

The article discusses adding custom functionality to frameworks, focusing on understanding architecture, identifying extension points, and best practices for integration and debugging.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.