我刚刚开始与Symfony合作.我下载了sf_sandbox,我遇到了$ sf_params的问题.当我尝试使用任何方法时,例如$sf_params->has('status')我收到错误:
注意:未定义的变量:第14行/var/www/sf_sandbox/apps/frontend/modules/login/actions/actions.class.php中的sf_params致命错误:在/中的非对象上调用成员函数has()第14行的var/www/sf_sandbox/apps/frontend/modules/login/actions/actions.class.php
这是块:
public function executeIndex() {
if ($sf_params->has('status') && $sf_params->has('message')) { // <--line 14
if ($sf_params->get('status') == 'failed') {
$this->message = $sf_params->get('message');
}
}
}
Run Code Online (Sandbox Code Playgroud) 我有这个架构:
shop_products:
_attributes: { phpName: ShopProduct }
products_id: { phpName: Id, type: INTEGER, size: '11', primaryKey: true, autoIncrement: true, required: true }
products_quantity: { phpName: Quantity, type: INTEGER, size: '4', required: true }
products_model: { phpName: Model, type: VARCHAR, size: '12', required: false }
products_image: { phpName: Image, type: VARCHAR, size: '64', required: false }
products_price: { phpName: Price, type: DECIMAL, size: '15', scale: '4', required: false, defaultValue: '0.0000' }
products_date_added: { phpName: DateAdded, type: TIMESTAMP, required: true }
products_last_modified: …Run Code Online (Sandbox Code Playgroud) 我尝试生成自定义查询(我正在为网站开发搜索引擎).
这是要翻译的查询:
SELECT * FROM `offre_habitation`
WHERE `id_type_offre` = 2
AND `id_nature_offre` = 1
AND (`nb_pieces` = 2 or `nb_pieces` = 1 or `nb_pieces` = 3 or `nb_pieces` = 4)
AND (`id_secteur`=1 OR `id_secteur` = 2 or id_secteur = 3)
AND `surface_habitable` > 90
AND `prix` > 700
Run Code Online (Sandbox Code Playgroud)
请问你能帮帮我吗 ?
在我的项目中,我有多个模块:
1.成为赞助商
2.成为参展商
3.征集论文
4.等等
在这些模块中,我有一个表单供用户填写和提交数据.这就像一张登记表.如果注册成功,我会向用户的电子邮件发送"欢迎消息".此电子邮件模板适用于所有情况!
所以,我需要一个通用的函数,方法来调用以发送该电子邮件.我不想在每个动作中都写出来.因此,在该方法中,我可以获得邮件程序,用户文化等实例,就像在基本模块操作中一样.
请各位兄弟们帮忙!
我有一个表'评论',调查有一个字段引用另一个表'sf_guard_user'.在我放的那一刻
<?php echo $investigationComment->getUserId() ?>
Run Code Online (Sandbox Code Playgroud)
我得到外表行的id值.我希望能够获得名称字段值.
在我的项目中的其他地方,我能够从getUserId()中省略id,然后put-> getName()并且它带给我那个字段值,但是为此它不会出于某种原因.如何获取外键行的名称值?
我刚刚更改了我正在处理的symfony项目的模式(添加了一个表和几列)并运行了以下两个命令:
php symfony doc:generate-migrations-diff
php symfony doc:migrate
Run Code Online (Sandbox Code Playgroud)
以前这没有任何问题,但这次它吓坏了.我意外地给了两个相同名称的表,它合理地失败了,但是现在我修复了我的模式文件它仍然无法工作.它会产生以下错误:
The following errors occurred:
- SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'media_images' already exists. Failing Query: "CREATE TABLE media_images (id INT UNSIGNED AUTO_INCREMENT, name VARCHAR(255), start_date DATE, end_date DATE, website VARCHAR(255), location TEXT, description TEXT, PRIMARY KEY(id)) ENGINE = INNODB"
- SQLSTATE[42S21]: Column already exists: 1060 Duplicate column name 'company_type'. Failing Query: "ALTER TABLE bio ADD company_type VARCHAR(255)"
- SQLSTATE[42S21]: Column already exists: 1060 Duplicate column name 'company'. Failing …Run Code Online (Sandbox Code Playgroud) 我使用symfony 1.4
在我的索引页面中,我创建了一些字段作为登录表单.
使用sfGuardPlugin时,它会自动生成其表单.
所以,我正在寻找的是如何替换我创建的新创建的默认表单.
谢谢
我无法获得游戏的DB值:
Game:
actAs:
Timestampable: ~
columns:
id: { type: integer(4), primary: true, autoincrement: true, unsigned: true }
game_name: { type: string(100), notnull: true }
logo: { type: string(100), notnull: true, comment: "Game Logo" }
indexes:
it:
fields: game_name
type: unique
Campaign:
actAs:
Timestampable: ~
columns:
id: { type: integer(4), primary: true, autoincrement: true, unsigned: true }
name: { type: string(100), notnull: true }
percentage: { type: integer(4), notnull: true, unsigned: true }
is_active: { type: integer(1), notnull: true, unsigned: true …Run Code Online (Sandbox Code Playgroud) 用户有更多任务,1:N连接.
视觉:
admin
task1 2011/01/01 00:00:01
task2 2011/01/01 00:00:04
task3 2011/01/01 00:00:02
user2
task1 2011/03/01 00:01:01
task2 2011/03/01 00:01:04
task3 2011/03/01 00:01:02
Run Code Online (Sandbox Code Playgroud)
(参见上一个问题的架构)
如何离开加入用户和最后的"任务",而不是全部?
问题是我不知道如何用纯SQL做到这一点......我在这里看到了一些例子,但它们没有用.
对于包含大量文本和html标记的页面,由于意外的特殊字符,我很快就会从Twig中获得解析错误.还有其他人遇到过这个问题吗?
Unexpected character "!" in ... at line 76
我试图通过粘贴新页面中的静态信息,然后使用包含它来解决此问题include.
我的问题是,我应该在哪里放置一个静态HTML文件,以便它可以包含在Twig文件中使用{% include 'content.html' %}?目前,包含的文件位于FooBundle/Resources/views/Default目录中.
克服这个问题的好习惯是什么,如果包含答案,文件应放在哪里以包含在树枝中?
注意:
当我尝试使用它链接到它时,{% include 'content.html' %}我得到以下Symfony错误:
Unable to find template "content.html" in ... at line 31 (断链)