我想这样做,以便任何时候查询数据库,sfGuardUserProfile它是自动连接和水合与其相关sfGuardUser.
如果我使用的是Propel 1.2,我通常会覆盖类的doSelectStmt方法sfGuardUserProfilePeer来检查Criteria并根据需要修改它,以及修改类的hydrate方法sfGuardUserProfile.我不知道如何在Doctrine中这样做.
我试图找到一种更好的方法来分配类来形成symfony中的元素.目前,我似乎无法手动分配每一个.即:
$this->widgetSchema['title']->setAttribute("class","fieldInput");
$this->widgetSchema['tag_line']->setAttribute("class","fieldInput");
$this->widgetSchema['description']->setAttribute("class","fieldInput");
// etc
Run Code Online (Sandbox Code Playgroud)
我尝试过没有成功的事情
1)循环遍历$ this-> widgetSchema,将其视为一个数组并将属性设置为每个键
2)$ this-> widgetSchema-> setAttribute()但这只是将类应用于生成的标签,而不是表单元素
必须有一种方法来击中所有的领域,而无需专门指导他们?
谁能指出我正确的方向?
我的网站上有一个地址,如下所示:
在这个例子中,查询字符串的'gigaom.com'部分中的点与lighttpd和我的重写规则紧密相关.我得到一个带有点的404,如果我把点拿出来没有404.我的重写规则如下.万一它有所作为,我正在使用symfony 1.4.
如果有人能对这个问题有所了解,我将不胜感激!
url.rewrite-once = (
"^/(.*\..+)$" => "$0",
"^/(.*)\.(.*)" => "/index.php",
"^/([^.]+)$" => "/index.php/$1",
"^/$" => "/index.php"
)
Run Code Online (Sandbox Code Playgroud)
对于任何遇到lighttpd和symfony问题的人(我知道你在那里,因为这个问题有很多未解决的问题)我最终解决并在下面回答它.
我尝试覆盖属性getter方法(由sfDoctrineRecord :: __ call()方法处理),如下所示:
//myClass.class.php
public function getProperty()
{
$property = parent::getProperty();
//the following line is never reached
return $property;
}
Run Code Online (Sandbox Code Playgroud)
但这导致无限递归.有可能吗?怎么样?
我试图在我的Symfony 1.4项目中使用sfDoctrineGuardPlugin.此插件包含一个schema.yml文件,该文件用于定义所涉及的所有表.表名采用以下形式:sf_guard_user,sf_guard_user_group,sf_guard_user_permission等.我宁愿将这些表命名为:users,user_groups,user_permissions等.有没有办法让我这样做而无需直接编辑插件代码?
正如标题所示,我正在寻找一种使用Symfony框架验证电子邮件(或其他字符串格式)的方法(无需使用表单框架).
我做了一些搜索,但给出的每个例子都是使用Form类...
而且我知道我可以使用外部类或库,但我只是好奇我是否可以在Symfony中使用它可以工作.
这样的事情是理想的:
$email = "email@to.validate";
$validator = new sfEmailValidator(); // just using this as an example - I know it doesn't work :p
$validator->check($email); // returns true or false if it validates
Run Code Online (Sandbox Code Playgroud) 有mysql_real_escape_string学说吗?
因为我有一个类似的查询
?´## '´` ^#11 " dfvü:?=._`ßß?(%%/ '
在我付诸之前,我必须逃避它 Doctrine_Query::create()
是否可以从模型层设置(或检索)cookie?
假设模型层用于"业务逻辑",我需要的逻辑需要与请求和响应进行一些交互.
我有两个表在schema.yml中没有相互定义的关系.但是,表1具有对表2的主键的外键引用.显然,我没有很好地设计数据库,但现在是缓解时间.
我必须在两个表之间进行左连接,并使用where子句来检索我想要的选择行.要做到这一点,我做:
Doctrine_Query::create()->select('t.*, l.lid')->from('Taxonomy t')->leftJoin('t.Cid c') ->leftJoin('c.Lesson l')->where('t.section = ?','Critical reading');
Run Code Online (Sandbox Code Playgroud)
这通常应该这样做,但它不会,因为它返回的是分类表中的所有行,而不管where条件.我在想,这是因为列中没有指定关系吗?这将是荒谬的,因为查询工作,只有在它没有的学说上下文.
谢谢
我正在尝试在我的查询中添加以下条件
AND momento_distribution.MOMENTO_IDMEMBER IN ( 5, 1, 3, 10, 11, 12, 18, 32, 51, 6 )
Run Code Online (Sandbox Code Playgroud)
为此,我有以下代码
$friendCsv=Friend::getFriendIdAsCsv($member); //returning string 5, 1, 3, 10, 11, 12, 18, 32, 51, 6
//code
$c->add(MomentoDistributionPeer::MOMENTO_IDMEMBER, $friendCsv, Criteria::IN);
Run Code Online (Sandbox Code Playgroud)
查询失败,因为它正在生成
AND momento_distribution.MOMENTO_IDMEMBER IN ( '5, 1, 3, 10, 11, 12, 18, 32, 51, 6' )
Run Code Online (Sandbox Code Playgroud)
在字符串上添加单引号.如果我手动删除该单引号,查询将成功运行.
有没有办法强制推动不要将单引号放在值中?
symfony1 ×10
doctrine ×4
symfony-1.4 ×3
php ×2
sfguard ×2
cookies ×1
doctrine-1.2 ×1
escaping ×1
join ×1
lighttpd ×1
mod-rewrite ×1
model ×1
plugins ×1
propel ×1
validation ×1