S
S
Sergey Shevchenko2017-06-13 20:16:44
PHP
Sergey Shevchenko, 2017-06-13 20:16:44

How to force propel to escape the name of the table to which the request goes, so that the name does not match the reserved word?

Hi all. Please tell me the solution to this problem, maybe someone faced it, How to make propel escape the name of the table to which the request is made, so that the name does not match the reserved word?
There is a table `Option`
When I try to write

$models = OptionQuery::create()->orderByName()->paginate($page, self::PAGE_SIZE_LIMIT);

then the error
Unable to execute COUNT statement [SELECT COUNT(*) FROM Option]
View error for details
0168d47722894a59a7f10dc637e69f4f.png
  • #0 /vagrant/vendor/propel/propel/src/Propel/Runtime/ActiveQuery/ModelCriteria.php(1388): Propel\Runtime\ActiveQuery\Criteria->doCount(Object(Propel\Runtime\Connection\DebugPDO))
  • #1 /vagrant/vendor/propel/propel/src/Propel/Runtime/ActiveQuery/ModelCriteria.php(1367): Propel\Runtime\ActiveQuery\ModelCriteria->doCount(Object(Propel\Runtime\Connection\DebugPDO))
  • #2 /vagrant/vendor/propel/propel/src/Propel/Runtime/Util/PropelModelPager.php(104): Propel\Runtime\ActiveQuery\ModelCriteria->count(NULL)
  • #3 /vagrant/vendor/propel/propel/src/Propel/Runtime/ActiveQuery/ModelCriteria.php(1440): Propel\Runtime\Util\PropelModelPager->init(NULL)
  • #4 /vagrant/application/modules/default/services/Option.php(28): Propel\Runtime\ActiveQuery\ModelCriteria->paginate(1, 50)
  • #5 /vagrant/application/modules/storage/controllers/OptionController.php(56): Service_Option->search(1)
  • #6 /vagrant/vendor/zendframework/zendframework1/library/Zend/Controller/Action.php(516): Storage_OptionController->indexAction()
  • #7 /vagrant/vendor/zendframework/zendframework1/library/Zend/Controller/Dispatcher/Standard.php(308): Zend_Controller_Action->dispatch('indexAction')
  • #8 /vagrant/vendor/zendframework/zendframework1/library/Zend/Controller/Front.php(954): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Vento_Controller_Response_Http))
  • #9 /vagrant/vendor/zendframework/zendframework1/library/Zend/Application/Bootstrap/Bootstrap.php(105): Zend_Controller_Front->dispatch()
  • #10 /vagrant/application/modules/BootstrapTrait.php(18): Zend_Application_Bootstrap_Bootstrap->run()
  • #11 /vagrant/vendor/zendframework/zendframework1/library/Zend/Application.php(384): Vento_BootstrapAbstract->run()
  • #12 /vagrant/public/index.php(38): Zend_Application->run()
  • #13 {main}
The problem is only when accessing this table, when accessing other tables, everything goes fine.
Storm says Option is a reserved keyword in MySQL

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Aksentiev, 2017-06-13
@lancer_serega

https://stackoverflow.com/a/36107595
But I would still change the name of the table in order to avoid possible jambs in the future, if I accidentally forget about it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question