您必須實施命名策略才能獲得camelCase自動生成的列名,如explained in Doctrine documentation。
做一個類來獲得駝峯名稱爲您的列名,CamelCaseNamingStrategy.php:
<?php
class CamelCaseNamingStrategy implements NamingStrategy
{
public function classToTableName($className)
{
return 'cc_' . substr($className, strrpos($className, '\\') + 1);
}
public function propertyToColumnName($propertyName)
{
return $propertyName;
}
public function referenceColumnName()
{
return 'id';
}
public function joinColumnName($propertyName, $className = null)
{
return strtolower($propertyName) . ucwords($this->referenceColumnName());
}
public function joinTableName($sourceEntity, $targetEntity, $propertyName = null)
{
return strtolower($this->classToTableName($sourceEntity)) . ucwords($this->classToTableName($targetEntity));
}
public function joinKeyColumnName($entityName, $referencedColumnName = null)
{
return strtolower($this->classToTableName($entityName)) . ($referencedColumnName ?: ucwords($this->referenceColumnName()));
}
}
然後註冊這個新類的服務,並將其添加到您的config.yml:
orm:
#...
entity_managers:
default
naming_strategy: my_bundle.camel_case_naming_strategy.default
你可以c/p查詢嗎? –
你的意思是什麼*顯示SQL結果的名稱*? – Wilt
好的。我會更詳細地解釋。我的實體'TFixed.php',它的內容如下。 '命名空間RestBundle \ Entity; 使用Doctrine \ ORM \ Mapping作爲ORM; /** * TFixedFees * * @ORM \表() * @ORM \實體(repositoryClass = 「RestBundle \實體\ TFixedRepository」) */ 類TFixed { /** * @var整數 * * @ORM \列(名稱= 「USER_ID」,類型= 「整數」) */ 私人$ USERID;' ,當我做任何SQL查詢,其結果數組將有'{ 'USER_ID': '67637673'}'。但我需要的結果是在駱駝案件。 –