应用程序在app_dev.php中工作,但在app.php中不可见



我真的很困惑。我使用Symfony 2.7和条令作为其原生ORM。因此,当我使用app_dev.php启动它时,一切都能正常工作,但当我使用apps.hp.启动它时

它就是不起作用。日志中显示

[2017-11-27 09:02:51] request.CRITICAL: Uncaught PHP Exception DoctrineDBALDBALException: "An exception occurred while executing 'SELECT t1.id AS id2, t1.code AS code3, t1.created AS created4, t1.updated AS updated5, t1.template_code AS template_code6, t1.label_attribute_id AS label_attribute_id7 FROM pim_catalog_family t1 WHERE t0.code = ? LIMIT 1' with params ["city_actions"]:  SQLSTATE[42S22]: Column not found: 1054 Unknown column 't0.code' in 'where clause'" at /var/www/html/pim-community-standard/vendor/doctrine/dbal/lib/Doctrine/DBAL/DBALException.php line 91 {"exception":"[object] (Doctrine\DBAL\DBALException(code: 0): An exception occurred while executing 'SELECT t1.id AS id2, t1.code AS code3, t1.created AS created4, t1.updated AS updated5, t1.template_code AS template_code6, t1.label_attribute_id AS label_attribute_id7 FROM pim_catalog_family t1 WHERE t0.code = ? LIMIT 1' with params ["city_actions"]:nnSQLSTATE[42S22]: Column not found: 1054 Unknown column 't0.code' in 'where clause' at /var/www/html/pim-community-standard/vendor/doctrine/dbal/lib/Doctrine/DBAL/DBALException.php:91, PDOException(code: 42S22): SQLSTATE[42S22]: Column not found: 1054 Unknown column 't0.code' in 'where clause' at /var/www/html/pim-community-standard/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php:694)"} [] 

这确实是可以自我解释的,所以它找不到t0,因为它不存在。我已经尝试过清除条令缓存和应用程序的一般缓存,但都不起作用。我用过这个命令-

php app/console doctrine:cache:clear-metadata 
php app/console doctrine:cache:clear-query  
php app/console doctrine:cache:clear-result
php app/console cache:clear --env=prod

有人知道这里发生了什么吗?

编辑:

<?php
/**
* Created by PhpStorm.
* User: nebo
* Date: 2.11.17.
* Time: 10.50
*/
namespace IcleiBundleBackendBundleEntity;
use PimBundleCatalogBundleEntityFamily as BaseFamily;
class Family extends BaseFamily
{
protected $template_code;
/**
* @return mixed
*/
public function getTemplateCode()
{
return $this->template_code;
}
/**
* @param mixed $template_code
*/
public function setTemplateCode($template_code)
{
$this->template_code = $template_code;
}
}

这是我的家人

BundleBackendBundleEntityFamily:
type: entity
table: pim_catalog_family
changeTrackingPolicy: DEFERRED_EXPLICIT
repositoryClass: PimBundleCatalogBundleDoctrineORMRepositoryFamilyRepository
uniqueConstraints:
pim_category_code_uc:
columns:
- code
fields:
template_code:
type: text
nullable: true

强制清除缓存:

rm -rf var/cache/*

确保该列存在,并且您的映射有效:

bin/console -e=prod doctrine:schema:validate

这里没有魔法。

因此,这个问题的答案在于config_prod.yml,它与config_dev.yml略有不同。

它在缓存机制上有所不同。我的config_prod.yml 的外观

imports:
- { resource: config.yml }
doctrine:
orm:
entity_managers:
default:
metadata_cache_driver: apc
result_cache_driver:   apc
query_cache_driver:    apc
monolog:
handlers:
main:
type:         fingers_crossed
action_level: warning
handler:      nested
nested:
type: stream
path: %kernel.logs_dir%/%kernel.environment%.log
level: info
console:
type:  console
oro_assetic:
css_debug:      ~
css_debug_all:  false

我的config_dev.yml 的外观

imports:
- { resource: config.yml }
framework:
router:   { resource: "%kernel.root_dir%/config/routing_dev.yml" }
profiler: { only_exceptions: false }
web_profiler:
toolbar: true
intercept_redirects: false
monolog:
handlers:
main:
type:  stream
path:  "%kernel.logs_dir%/%kernel.environment%.log"
level: debug
firephp:
type:  firephp
level: info
oro_assetic:
css_debug:      ~
css_debug_all:  false
swiftmailer:
disable_delivery: true
parameters:
apy_js_form_validation.yui_js: false

我刚刚从config_prod.yml中评论出了条令,突然间一切都正常了:-)或者你也可以在你的生产中启用APC,然后它也会起作用。

相关内容

  • 没有找到相关文章

最新更新