我将symfony2项目上传到服务器树丛.主页面加载,但所有链接都被破坏.我尝试将app.php添加到网址中.它确实有效,但是:
我有这样的路线:
www.something.com/app.php/something
我希望他们是:
www.something.com/something.
我一直在阅读,我应该在.htaccess上加上一些重写规则.
我发现了这些规则,但它们似乎不起作用:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ app.php [QSA,L]
</IfModule>
Run Code Online (Sandbox Code Playgroud) 所以我正在阅读Symfony2 Book的安全章节.我理解一切,但如果有登录错误,我想自定义错误消息.
我可以在哪个文件中更改此内容?
这是模板:
{% if error %}
<div>{{ error.message }}</div>
{% endif %}
<form action="{{ path('login_check') }}" method="post">
<label for="username">Username:</label>
<input type="text" id="username" name="_username" value="{{ last_username }}" />
<label for="password">Password:</label>
<input type="password" id="password" name="_password" />
{#
If you want to control the URL the user is redirected to on success (more details below)
<input type="hidden" name="_target_path" value="/account" />
#}
<input type="submit" name="login" />
Run Code Online (Sandbox Code Playgroud)
我相信这样做的最糟糕方式是:
if (error.message=="Bad credentials")
echo "Los datos son erróneos :)"
if (error.message==The presented password is invalid") …Run Code Online (Sandbox Code Playgroud) 我正在关注Symfony 2书的安全章节.
有一个表USERS和一个例子GROUPS.有一个许多一对多的关系USERS和GROUPS,这在数据库称为表中创建USERGROUPS.
我想要的是删除一个记录USERGROUPS,例如:
DELETE from USERGROUPS WHERE user_id = 1 and group_id = 1
Run Code Online (Sandbox Code Playgroud)
我不知道怎么做,因为我没有USERGROUPS.php表格文件.
例如,使用DQL,我希望能够这样做:
$em = $this->getDoctrine()->getEntityManager();
$query = $em->createQuery(
'DELETE FROM AcmeStoreBundle:UserGroups ug WHERE ug.user_id = :user
and ug.group_id = :group'
)->setParameter(array('user' => $userid, 'group' => $groupid));
Run Code Online (Sandbox Code Playgroud)
我希望你明白这个主意.
那么,我该如何从这张表中删除?
所以我有这个.html文件,我必须分析.在那个文件中我有这样的行:
<tr>
<td colspan=1 rowspan=1 bgcolor=#ffffff align=left valign=top>
<font size=1 face="Tahoma" color=#000000>
<nobr>
240,0000
</nobr>
</font>
</td>
<td colspan=1 rowspan=1 bgcolor=#ffffff align=left valign=top>
<font size=1 face="Tahoma" color=#000000>
<nobr>
340,0000
</nobr>
</font>
</td>
</tr>
Run Code Online (Sandbox Code Playgroud)
我需要得到的是240,0000,340,0000等等.我尝试过这样的事情:
// Create DOM from URL or file
$html = file_get_html('File.html');
foreach($html->find('td') as $element)
echo $element->text. '<br>';
Run Code Online (Sandbox Code Playgroud)
这样做我没有得到我想要的文本.
如何引用标签内的文字?所以我可以得到价值观.
我最后一次登录时有没有办法存储?
我正在使用symfony2,一切正常,安全配置正常.
我已经看到这个安全性并登录基于Symfony 2的项目,这是一个类似的问题,但它不符合我的需求.
还有其他解决方案吗?
西班牙语特殊字符显示不正确,如下所示:'Árbol'显示为' bol'.
1)正确保存数据库中的文本.'Árbol'在数据库上看起来很完美.
2)如果我插入一个新单词,例如.'Tétrico',它在数据库中正确保存.
我一直遇到这个问题,因为我将项目移动到另一台服务器,在localhost(Ubuntu服务器)上工作完美.
我尝试了所有阅读类似问题的内容:
在my.cnf中,我添加了以下行:
init_connect ='SET NAMES utf8'
被character_set_server = UTF8
它只是不起作用.
我还可以做些什么?
我已经在localhost上复制了我所做的更改(因为项目在这里工作得很好,所有内容都正确显示)到新服务器,但没有任何改变.
我正在使用Symfony2 Framework,我想用表单中的数据更新实体.
我使用相同的控制器用一些数据填充表单,同时我用它来在数据库中进行更新查询.如果我使用$ em-> persist($ foo)它确实保存了我想要的东西,但我不想像它的新数据一样保存它,我想要更新.
阅读symfony2书,它说$ em-> flush()就是我们所需要的,所以我们可以更新.
我想我真的很亲密但当然我错过了一些东西.
这是代码:
public function actualizarCurriculoAction($id){
$curriculo = new Curriculittle();
$form = $this->createForm(new CurriculittleType(), $curriculo);
$request = $this->getRequest();
if ($request->getMethod() == 'POST') {
$form->bindRequest($request);
$lselect=$this->get('request')->request->get('lselect');
$edad=$this->get('request')->request->get('edad');
$estado=$this->get('request')->request->get('estadoselect');
if ($form->isValid()) {
$curriculo->setUsalentes($lselect);
$curriculo->setEdad($edad);
$curriculo->setEstado($estado);
$em = $this->getDoctrine()->getEntityManager();
/*em->persist($curriculo);*/
$em->flush(); /*the above line is in comment because I just want to update*/
/*At this point the entity should be updated, but it's not*/
/*Llamando a la plantilla de listados*/
$curriculos = $em->getRepository('SofLaSoflaBundle:Curriculittle')->findAll();
/*Enviando los …Run Code Online (Sandbox Code Playgroud) 我需要找到一个doctrine函数,允许我查询数据库表的所有名称.
我找到了解决方案,例如这个.(您需要将实体放入函数,它将返回表的名称.)
$em = $this->getDoctrine()->getEntityManager();
$tableName = $em->getClassMetadata('StoreBundle:User')->getTableName();
Run Code Online (Sandbox Code Playgroud)
这不是我需要的.我在SQL中会做的是:
show tables in database_name;
Run Code Online (Sandbox Code Playgroud)
它返回数据库中所有表的名称.
我需要使用Doctrine来做到这一点.
symfony ×5
php ×3
doctrine ×2
login ×2
.htaccess ×1
codeigniter ×1
dql ×1
forms ×1
many-to-many ×1
messages ×1
mod-rewrite ×1
mysql ×1
security ×1
utf-8 ×1