我正在使用cakephp作为我的Web应用程序.我有一个数据库表,我存储了一些以纯文本保存的文字.我能做什么,我可以得到它自己格式化的文本我html标记?
例如,我在数据库上有一个文本,如:
blablablabalbalblablablablablablablablabalbalbla.
otherotherotherotherotherother.
helloworldhelloworldhelloworldhelloworld.
Run Code Online (Sandbox Code Playgroud)
但是,当我得到它时,它显示如下:
blablablabalbalblablablablablablablablabalbalbla.otherotherotherotherotherother.helloworldhelloworldhelloworldhelloworld.
Run Code Online (Sandbox Code Playgroud)
但是我希望它像这样进入html:
<p>blablablabalbalblablablablablablablablabalbalbla.</p>
<p>otherotherotherotherotherother.</p>
<p>helloworldhelloworldhelloworldhelloworld.</p>
Run Code Online (Sandbox Code Playgroud)
无论如何要做到这一点?
我想知道如何从cakephp中删除"使用CakePHP框架发送此电子邮件".我从/app/View/Layouts/Emails/html/default.ctp
和中删除了这个文本/app/View/Layouts/Emails/text/default.ctp
.但没有变化.我也把它从/app/View/Emails/html/default.ctp
和中删除了/app/View/Emails/text/default.ctp
.再也没有变化.我该怎么做?
cakephp的新功能遇到了我必须将文本和图像作为链接的场景.幸运的是它是成功的,但是我注意到我的链接上有一个下划线,我必须删除它,你可以在下面的图片上看到+关于我是如何做到这样的代码:
Cakephp代码:
echo $this->Html->link(
$this->Html->image('img/f.png', array('height' => '40', 'width' => '40'))
. '' . ('forensics express    '),
'http://example.com', array('escape' => false));
Run Code Online (Sandbox Code Playgroud)
通常只需添加以下内容即可:
style="text-decoration:none"
Run Code Online (Sandbox Code Playgroud)
在css中,但是因为我是蛋糕的新手,所以我不知道如何设置我可以用于css的id或类的语法,或者我喜欢的语法,直接添加style ="text-decoration :无"在阵列中.我试过这个,但它不起作用.
echo $this->Html->link(
$this->Html->image('img/f.png', array('height' => '40', 'width' => '40'))
. '' . ('forensics express    '),
'http://example.com', array('escape' => false,'style'=>'text-decoration:none'));
Run Code Online (Sandbox Code Playgroud)
我怎么解决这个问题?任何帮助表示赞赏
我刚刚完成了CakePHP文档中的Blog教程。这很简单又有趣。但是我对一件事感到困惑。在CakePHP中创建博客时,我的“帖子”表中有两个字段,“创建”和“修改”。
CakePHP会在那里自动进行所有更新。我没有为此写任何代码。
现在,在完成该教程之后,我想制作一个简单的注册表格以及一个“登录”页面。现在,我的问题是我必须在数据库中使用哪些字段名,以便CakePHP为每个用户自动更新“注册日期和时间”和“上次登录”。
哦,而且,如果我的表“ users”中有一个“ password”字段,那么CakePHP在将密码存储到数据库之前会自动对密码进行哈希处理吗?如果这样做,将使用哪种哈希算法?如果我在“用户”表中有一个单独的“盐”字段,那么它也会自动处理吗?
我的 mysql 数据库中有 7 条记录,每条记录都对应于 0-6 的星期几
现在我想显示我的 PHP 脚本,而不是 0,'Sunday' 或代替 1 想显示'Monday'。
是否有任何函数可以使用星期几并返回星期几的名称?
我想使用CakePHP表单助手显示--Select--作为默认值,并且默认选择此值.
当前代码:
echo $this->Form->month('m');
echo $this->Form->day('d');
echo $this->Form->year('y');
Run Code Online (Sandbox Code Playgroud)
谢谢.
我基本上试图通过返回Project和Update表的Users和Comments来扩展查询的深度.
网站访问者可以查看项目,该项目下面列出了许多更新.
用户可以在下面的初始项目和更新中留下评论,每个更新和项目都由任何用户提交.
我设置了以下关系,但这些可能是错误的:
Project.php (Model)
belongsTo - User
hasMany - Update, Comment
Update.php (Model)
belongsTo - Project, User
hasMany - Comment
Comment.php (Model)
belongsTo - Project, Update
hasAndBelongsToMany - User
User.php (Model)
hasMany - Project, Update, Comment
Run Code Online (Sandbox Code Playgroud)
ProjectController.php中的视图如下:
public function view($id = null, $slug = null) {
$this->Project->id = $id;
$this->set('Projects', $this->Project->read());
}
Run Code Online (Sandbox Code Playgroud)
但这只导出一个包含以下内容的数组
Project
User (belonging to Project)
Comments (belonging to Project)
Updates (belonging to Project)
Run Code Online (Sandbox Code Playgroud)
但我想要这个完整的结果,包含对所有内容和用户的评论:
Project
User (belonging to Project)
Comments (belonging to Project)
User (belonging …
Run Code Online (Sandbox Code Playgroud) 我需要找到前两篇文章.可以说,我从数据库中得到了一篇文章:
Array
(
[0] => Array
(
[Pressroom] => Array
(
[id] => 44
[created] => 2013-04-17 07:38:20
[date] => 2013-04-17
[modified] => 2013-04-23 07:58:25
)
)
Run Code Online (Sandbox Code Playgroud)
我还需要找到两个优先记录(让我们说id 43和42).任何sugestions?我完全不知道.
我试图在我的模型中使用此代码:
$this->find('all',
array(
'order' => array(
'Pressroom.date' => 'DESC',
'Pressroom.created' => 'DESC'
),
'limit' => 2,
'conditions' => array('Pressroom.date <' => $data['Pressroom']['date'])));
Run Code Online (Sandbox Code Playgroud)
但它找到两个id为1和2的记录,而不是43和42
我有一个mysql查询如下:
select * from users where email='xxx@xxx.com' and password = SHA1(CONCAT(SHA1(SHA1("123456")),salt))
Run Code Online (Sandbox Code Playgroud)
我想转换为蛋糕PHP查找使用beforSave功能:
public function beforeFind(array $queryData) {
if(isset($queryData['conditions']['User.password'])) {
$queryData['conditions']['User.password'] = 'SHA1(CONCAT(SHA1(SHA1("'.$queryData['conditions']['User.password'].'")),User.salt))';
}
$this->log($queryData);
return $queryData;
}
Run Code Online (Sandbox Code Playgroud)
mysql查询运行okie但在cakephp中发现这不起作用.
谢谢你的帮助.
我正在CakePHP中构建一个API.我有一个功能,作为其执行的一部分首先破坏与会话相关的cookie.我使用以下代码来执行此操作.
public function new_thing () {
// I first call another controller to use functions from that controller
App::import('Controller', 'Person');
$PersonsController = new PersonsController;
// This function call is the problem
// This does not throw any errors but does not destroy the cookie as requested
$PersonsController->_kill_auth_cookie()
}
// This is from the Person controller, these are the functions used in the API
// This is the function that sets the cookies
public function _set_auth_cookie( $email ) {
setcookie(Configure::read('auth_cookie_name'), $email); …
Run Code Online (Sandbox Code Playgroud)