Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/255.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Symfony 1.4路由:来自不同类的字段_Php_Symfony1_Symfony 1.4 - Fatal编程技术网

Php Symfony 1.4路由:来自不同类的字段

Php Symfony 1.4路由:来自不同类的字段,php,symfony1,symfony-1.4,Php,Symfony1,Symfony 1.4,如何创建路由并将其与来自不同类的字段相匹配? 可能吗?是否有自定义路由类 例如,我有两门课: File: columns: name: { type: string(255), unique: true, notnull: true } ... Link: columns: file_id: { type: bigint, notnull: true } ticket: { type: string(64), notnull: true } rela

如何创建路由并将其与来自不同类的字段相匹配? 可能吗?是否有自定义路由类

例如,我有两门课:

File:
  columns:
    name: { type: string(255), unique: true, notnull: true }
    ...

Link:
  columns:
    file_id: { type: bigint, notnull: true }
    ticket: { type: string(64), notnull: true }
  relations:
    File:
      local: file_id
      foreign: id
      foreignAlias: links
  ...
现在假设我想创建这样一条路由:
mysite.com/:ticket/:name
如您所见,
ticket
Link
表的一个字段,
name
文件
表的一个字段。有没有办法在symfony 1.4中创建这样的链接

第一种解决方案是更改
文件
表的主键并将其设置为其名称。我知道这一点,但我想知道是否有办法通过路由来处理这个问题


我的目标是,当我调用getObject方法时,它返回一个带有已发送票证的链接对象,但是还应该检查是否存在以及与已发送文件名的关系。

IIRC您可以这样做:

my_route:
  url: /:ticket/:name
  class: sfDoctrineRoute
  param: { module: yourModule, action: yourAction }
  options: { type: object, model: Link, method: findLinkWithSendTicket }
然后symfony应该调用
LinkTable::findLinkWithSendTicket
方法并向其传递参数,以便您可以使用它来获取对象

链接可能会有所帮助: