我对WP很新.任务是在一个不流行的openID提供程序上开发oauth身份验证插件.我对CodeIgniter项目做了同样的事情,但WP是一个CMS,对我来说有点复杂.在Codeigniter中,我会在每次操作之前检查授权.在WP中我需要一个用于它的钩子...在每个页面打印之前,或者可能......在每个动作之前就框架来说是正确的.这个钩子的名字是什么?
public function up(){
$this->createTable('POST', array(
'id' => 'pk',
'isremoved' => 'integer NOT NULL',
'removaldate' => 'timestamp NULL',
'post' => 'text NOT NULL',
'creationdate' => 'timestamp NOT NULL',
));
}
Run Code Online (Sandbox Code Playgroud)
这是迁移的 up 函数。如您所见,它是创建新表的查询。默认情况下,YII 为时间戳列创建默认值等于 CURRENT_TIMESTAMP 并创建附加参数并将其设置为等于 ON UPDATE CURRENT_TIMESTAMP。
我不需要时间戳的当前值,也不需要在更新行时更新此列。我必须做什么?顺便说一句,你使用 MySQL
我像这样设置默认控制器
$route['default_controller'] = "InterviewController";
Run Code Online (Sandbox Code Playgroud)
这是InterviewController的代码
class InterviewController extends CI_Controller{
private $em;
function __construct() {
parent::__construct();
}
public function index() {
$commentsList = array();
$commentsList['comments'] = $this->em->getRepository('Entities\Comment')->findPage(1, 10, 'DESC', $this->em->getRepository('Entities\Interview')->getLast()[0]->getId());
$lastInterviewsAnons = array();
$lastInterviewsAnons['lastInterviewsAnons'] = $this->em->getRepository('Entities\Interview')->getLast();
$this->load->view('header');
$this->load->view('navbar');
$this->load->view('content', $lastInterviewsAnons);
$this->load->view('addCommentPanel');
$this->load->view('commentsList', $commentsList);
$this->load->view('footer');
}
}
Run Code Online (Sandbox Code Playgroud)
一切都在我的本地机器上完美,但在服务器上我得到404错误.我只能通过键入http://mydomain.com/index.php/InterviewController等完整网址来访问此控制器.好像路线文件中的指令不起作用.你有什么建议吗?
我在CodeIgniter控制器中尝试使用Doctrine模型时得到了"Message:class_parents():Class Comment不存在且无法加载".
这是完整的堆栈跟踪致命错误:C:\ Users\user\Desktop\projects\interview\application\libraries\Doctrine\Common\Persistence\Mapping\RuntimeReflectionService.php中未捕获的异常'ReflectionException',消息'类注释不存在' :73堆栈跟踪:#0 C:\ Users\user\Desktop\projects\interview\application\libraries\Doctrine\Common\Persistence\Mapping\RuntimeReflectionService.php(73):ReflectionClass - > __ construct('Comment')#1 C:\ Users\user\Desktop\projects\interview\application\libraries\Doctrine\ORM\Mapping\ClassMetadataInfo.php(769):Doctrine\Common\Persistence\Mapping\RuntimeReflectionService-> getClass('Comment')#2 C :\ Users\user\Desktop\projects\interview\application\libraries\Doctrine\ORM\Mapping\ClassMetadataFactory.php(591):Doctrine\ORM\Mapping\ClassMetadataInfo-> initializeReflection(Object(Doctrine\Common\Persistence\Mapping \) RuntimeReflectionService))#3 C:\ Users\user\Desktop\projects\interview\application\libraries\Doctrine\ORM\Mapping\ClassMetadataFactory.p hp(272):Doctrine\ORM\Mapping\ClassMetadataFactory-> initializ位于第73行的C:\ Users\user\Desktop\projects\interview\application\libraries\Doctrine\Common\Persistence\Mapping\RuntimeReflectionService.php
这是我在/application/models/Entities/Comment.php中的模型
<?php
namespace Entities;
use Doctrine\ORM\Mapping as ORM;
/**
* Entities\Comment
*/
class Comment
{
/**
* @var integer $id
*/
private $id;
/**
* @var integer $parentid
*/
private $parentid;
/**
* @var integer $isactive
*/
private $isactive;
/**
* @var integer $isremoved
*/
private $isremoved;
/**
* @var datetime $removaldate
*/
private $removaldate; …Run Code Online (Sandbox Code Playgroud) 构建自定义实体存储库时遇到一些问题.
尝试自定义实体存储库时,我有以下致命错误
Fatal error: Uncaught exception 'BadMethodCallException' with message 'Undefined method 'getByParentId'. The method name must start with either findBy or findOneBy!' in C:\Users\user\Desktop\projects\interview\application\libraries\Doctrine\ORM\EntityRepository.php:215 Stack trace: #0 C:\Users\user\Desktop\projects\interview\application\controllers\CommentController.php(58): Doctrine\ORM\EntityRepository->__call('getByParentId', Array) #1 C:\Users\user\Desktop\projects\interview\application\controllers\CommentController.php(58): Doctrine\ORM\EntityRepository->getByParentId('1') #2 [internal function]: CommentController->viewCommentsListByParentId('1') #3 C:\Users\user\Desktop\projects\interview\system\core\CodeIgniter.php(359): call_user_func_array(Array, Array) #4 C:\Users\user\Desktop\projects\interview\index.php(203): require_once('C:\Users\user\D...') #5 {main} thrown in C:\Users\user\Desktop\projects\interview\application\libraries\Doctrine\ORM\EntityRepository.php on line 215
Run Code Online (Sandbox Code Playgroud)
我的项目结构是Mappings Repositories Entities Proxies模型
我的doctrine.php有这样的存储库加载器
// load the repositories
$repositoryClassLoader = new \Doctrine\Common\ClassLoader('Repositories', APPPATH.'models');
$repositoryClassLoader->register();
Run Code Online (Sandbox Code Playgroud)
我的模型类有以下声明
namespace Entities;
use Doctrine\ORM\Mapping as ORM;
/**
* Entities\Comment
* @Entity (repositoryClass="Repositories\CommentRepository") …Run Code Online (Sandbox Code Playgroud) php ×5
codeigniter ×2
doctrine-orm ×2
action ×1
autoload ×1
controller ×1
database ×1
doctrine ×1
hook ×1
migration ×1
routing ×1
wordpress ×1
yii ×1