我有自己的迷你php MVC,需要添加beberlei/DoctrineExtensions
。我无法弄清楚如何添加/配置和使用beberlei/DoctrineExtensions
.目前,我有这个配置:
require_once INC_ROOT . '/vendor/doctrine/common/lib/Doctrine/Common/ClassLoader.php';
use DoctrineCommonClassLoader;
$classLoader = new DoctrineCommonClassLoader('Doctrine');
$classLoader->register();
$classLoader2 = new DoctrineCommonClassLoader('DoctrineExtensions', '/vendor/beberlei/DoctrineExtensions');
$classLoader2->register();
我想选择类似于 20aliasApp871
的 appId,从任何数字开始,后跟aliasApp
字符串,然后是高于 870 的数字(但不超过 1500)。
$appIds = $qb->select( 'a.id' )
->from( 'BookBundleEntityApp', 'a' )
->where ( ' REGEXP(a.aliasApp, .*aliasApp[189]{1}[0123456789]{2,3}) = true ')
->getQuery()
->getResult();
我收到致命错误:
Fatal error: `Uncaught DoctrineORMQueryQueryException:
SELECT a.id FROM BookBundleEntityApp a WHERE REGEXP(a.aliasApp, .*aliasApp[189]{1}[0123456789]{2,3}) = true`
in vendordoctrineormlibDoctrineORMQueryQueryException.php:41 Stack trace:
#0 vendordoctrineormlibDoctrineORMQueryParser.php(448): DoctrineORMQueryQueryException::dqlError('SELECT a.id FRO...')
#1 vendordoctrineormlibDoctrineORMQueryParser.php(3379): DoctrineORMQueryParser->syntaxError('known function', Array)
#2 vendordoctrineormlibDoctrineORMQueryParser.php(3351): DoctrineORMQueryParser->CustomFunctionDeclaration()
#3 vendordoctrineormlibDoctrineORMQueryParser.php(2810): DoctrineORMQueryParser->FunctionDeclaration()
#4 vendordoctrineormlibDoctrineORMQueryQueryException.php on line 52
-
不要在表名中使用反斜杠。
-
REGEXP
是运算符,而不是函数:WHERE a.aliasApp REGEXP '.*aliasApp[189]{1}[0123456789]{2,3}'
-
向Doctrine抱怨没有提供MySQL给它的有用错误消息。