我有这个表:
A:
id
1
2
B:
id a_id
1 1
2 1
3 1
C:
id a_id
1 1
2 1
3 2
Run Code Online (Sandbox Code Playgroud)
我需要这个结果:
A, CountB, CountC
1, 3, 2
2, 0, 1
Run Code Online (Sandbox Code Playgroud)
这个尝试不起作用:
SELECT
A.id, COUNT(B.id), COUNT(C.id)
FROM
A
LEFT JOIN
B ON A.id = B.a_id
LEFT JOIN
C ON A.id = C.a_id
GROUP BY A.id
Run Code Online (Sandbox Code Playgroud)
如果不使用相关查询,sql句子必须如何?
我如何为表单身份验证提供程序设置success_handler(和failure_handler)?
Silex用这个配置忽略了我:
<?php
use WebFactory\Security\UserProvider;
$app->register(new Silex\Provider\SecurityServiceProvider(), array(
'security.firewalls' => array(
'dev' => array(
'pattern' => '^/(_(profiler|wdt)|css|images|js)/',
'security' => false
),
'default' => array(
'pattern' => '^/.*$',
'anonymous' => true,
'form' => array(
'login_path' => '/login',
'check_path' => '/login_check',
'success_handler' => 'authentication_handler', //<-- here
'failure_handler' => 'authentication_handler', //<-- here
),
'logout' => array('logout_path' => '/logout'),
'users' => $app->share(function () use ($app) {
return new UserProvider($app['db']);
}),
),
),
'security.access_rules' => array(
array('^/login', 'IS_AUTHENTICATED_ANONYMOUSLY'),
array('^/private$', 'ROLE_ADMIN'),
),
'security.role_hierarchy' => array(
'ROLE_SIMPLE_USER' …Run Code Online (Sandbox Code Playgroud) 我如何使用Doctrine queryBuilder为countDistinct expr设置别名?
$qb->addSelect($qb->expr()->countDistinct('_charges.id'));
Run Code Online (Sandbox Code Playgroud)