Я использую Symfony 1.4.11 с доктриной.Итак, часть схемы:
Companies:
actAs:
Timestampable: ~
Sluggable:
unique: true
fields: [company]
canUpdate: false
builder: [myTools, StripText]
connection: doctrine
tableName: companies
columns:
company_id: { type: integer(4), primary: true, notnull: true, autoincrement: true }
user_id: { type: int(4) }
category_id: { type: int(4), notnull: true }
company: { type: string(255), notnull: true }
address: { type: string(255), notnull: true }
contact_person: { type: string(255), notnull: true }
phone: { type: string(50), notnull: true }
fax: { type: string(50) }
email: { type: string(255), notnull: true}
url: { type: string(50) }
about: { type: string(1000), notnull: true}
country: { type: string(255), notnull: true}
show_ads: { type: boolean, default: 0 }
active: { type: boolean, default: 0 }
has_company: { type: boolean, default: 1 }
relations:
Owner: { onDelete: CASCADE, local: user_id, foreign: id, class: sfGuardUser, foreignAlias: Companies }
Images_companies: { local: company_id, foreign: company_id, type: many, class: Images_companies }
Categories: { onDelete: CASCADE, local: category_id, foreign: category_id , type: many, foreignType: one}
Categories:
actAs:
I18n:
fields: [name]
actAs:
Sluggable:
unique: true
fields: [name]
canUpdate: true
builder: [myTools, StripText]
NestedSet:
hasManyRoots: true
connection: doctrine
tableName: categories
columns:
category_id: { type: integer(4), primary: true, autoincrement: true }
name: string(255)
Я хочу, чтобы пользователь мог выбрать для компании более одной категории.Я использую sfWidgetFormDoctrineChoice, поэтому, когда у меня есть
$this->widgetSchema['category_id'] = new sfWidgetFormDoctrineChoice(array('model' => 'Categories', 'add_empty' => false, 'multiple' => false));
Пользователь может выбрать только одну категорию, все нормально.Когда у меня есть:
$this->widgetSchema['category_id'] = new sfWidgetFormDoctrineChoice(array('model' => 'Categories', 'add_empty' => false, 'multiple' => true));
И выберите только одну категорию из списка, в db save category_id = 0.Когда я выбираю более одной категории, у меня появляется ошибка: SQLSTATE [HY093]: недопустимый номер параметра: число связанных переменных не соответствует количеству токенов
Я ищу эту ошибку в Google,но я не нахожу решение, и я не сейчас, где я делаю что-то не так.Спасибо!