色雷斯数据网格实现jqGrid:Doctrine不会触发查询



我在Linux机器上使用Symfony,doctrine ORM,SQL Server。我正在尝试像 https://github.com/thrace-project/datagrid-bundle 一样实现色雷斯数据网格。我按原样按照步骤操作。这是我的代码: 索引.html.twig

{% extends "::base.html.twig" %}
{% block stylesheets %}
<link rel="stylesheet" type="text/css" media="screen" href="{{ asset('bundles/productorderlookup/css/ui-lightness/jquery-ui.css') }}" />
<link rel="stylesheet" type="text/css" media="screen" href="{{ asset('bundles/productorderlookup/css/ui.jqgrid.css') }}" />
{% endblock %}

{% block javascripts %}
{{ parent() }}
<script src="//code.jquery.com/jquery-1.11.2.min.js"></script>
<script src="//code.jquery.com/jquery-migrate-1.2.1.min.js"></script>
<script src="{{ asset('bundles/productorderlookup/js/init-datagrid.js') }}" type="text/javascript"></script>
<script src="{{ asset('bundles/productorderlookup/js/i18n/grid.locale-en.js') }}" type="text/javascript"></script>
<script src="{{ asset('bundles/productorderlookup/js/jquery.jqGrid.src.js') }}" type="text/javascript"></script>
<script src="{{ asset('bundles/thracedatagrid/js/init-datagrid.js') }}" type="text/javascript"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/i18n/jquery-ui-i18n.min.js"></script>
{% endblock %}
{% block body %}
<div>{{ thrace_datagrid('user_management') }}</div>
{% endblock %}

用户管理生成器.php

namespace ProductOrderUserOrderBundle;
use DoctrineORMEntityManager;
use SymfonyComponentRoutingRouterInterface;
use SymfonyComponentTranslationTranslatorInterface;
use ThraceDataGridBundleDataGridDataGridFactoryInterface;
class UserManagementBuilder
{
const IDENTIFIER = 'user_management';
protected $factory;
protected $translator;
protected $router;
protected $em;

public function __construct (DataGridFactoryInterface $factory, TranslatorInterface $translator, RouterInterface $router,
EntityManager $em)
{
$this->factory = $factory;
$this->translator = $translator;
$this->router = $router;
$this->em = $em;
}
public function build ()
{
$dataGrid = $this->factory->createDataGrid(self::IDENTIFIER);
$dataGrid
->setCaption($this->translator->trans('user_management_datagrid.caption'))
->setColNames(array(
$this->translator->trans('column.firstName'),
$this->translator->trans('column.lastName'),
$this->translator->trans('column.enabled'),
))
->setColModel(array(
array(
'name' => 'firstName', 'index' => 'u.firstName', 'width' => 200,
'align' => 'left', 'sortable' => true, 'search' => true,
),
array(
'name' => 'lastName', 'index' => 'u.lastName', 'width' => 200,
'align' => 'left', 'sortable' => true, 'search' => true,
),
array(
'name' => 'enabled', 'index' => 'u.enabled', 'width' => 30,
'align' => 'left', 'sortable' => true, 'search' => true,
'formatter' => 'checkbox', 'stype' => 'select',
'searchoptions' => array(
'value' => array(
1 => 'enable',
0 => 'disabled',
)
)
),
))
->setQueryBuilder($this->getQueryBuilder())
->enableSearchButton(true)
;
return $dataGrid;
}

protected function getQueryBuilder()
{
$qb = $this->em->getRepository('ProductOrderUserOrderBundle:User')->createQueryBuilder('u');
$qb
->select('u.id, u.firstName, u.lastName, u.enabled')
->groupBy('u.id')
;

return $qb;
}
}

默认控制器.php

namespace ProductOrderUserOrderBundleController;
use SymfonyComponentDependencyInjectionLoaderXmlFileLoader;
use SymfonyComponentConfigFileLocator;
use SymfonyBundleFrameworkBundleControllerController;
use SensioBundleFrameworkExtraBundleConfigurationRoute;
use SensioBundleFrameworkExtraBundleConfigurationTemplate;
use SymfonyComponentHttpfoundationRequest;

class DefaultController extends Controller
{
public function indexAction()
{
/** @var ThraceDataGridBundleDataGridDataGridInterface */
$userManagementDataGrid = $this->container->get('thrace_data_grid.provider')->get('user_management');
return $this->render('ProductOrderUserOrderBundle:Default:index.html.twig',array(
'userManagementDataGrid' => $userManagementDataGrid,
));
}
}

实体类用户.php

namespace ProductOrderUserOrderBundleEntity;
use DoctrineCommonCollectionsArrayCollection;
use DoctrineORMMapping as ORM;
/**
*  * @ORMTable(name="TSOFT_LEARN.dbo.User")
* @ORMEntity
*/
class User
{
/**
* @var integer
*
* @ORMId @ORMColumn(name="id", type="integer")
*
* @ORMGeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @var string
*
* @ORMColumn(name="firstName", type="string", length=255, nullable=true, unique=false)
*/
protected $firstName;
/**
* @var string
*
* @ORMColumn(name="lastName", type="string", length=255, nullable=true, unique=false)
*/
protected $lastName;
/**
* @var boolean
*
* @ORMColumn(name="enabled", type="boolean")
*/
protected $enabled = false;

public function __construct()
{
}
public function getId()
{
return $this->id;
}
public function setFirstName($firstName)
{
$this->firstName = $firstName;
}
public function getFistName()
{
return $this->firstName;
}
public function setLastName($lastName)
{
$this->lastName = $lastName;
}
public function getLastName()
{
return $this->lastName;
}
public function setEnabled($enabled)
{
$this->enabled = $enabled;
}
public function isEnabled()
{
return $this->enabled;
}

}

页面加载正常,但在Symfony工具栏上显示,没有触发查询。

如果我提供了太多代码,请道歉。

编辑:打印getDQL代码后,我得到了SELECT u.id, u.firstName, u.lastName, u FROM AppBundleUserPoBundleEntityUser u GROUP BY u.id

但是在我的学说调试窗口中,我仍然没有查询。

显然,当它连接到SQL Server时,Doctrine中存在一个错误。当我将同一个项目连接到PostgreSQL服务器时,一切正常。

更新:该错误与教义无关。当我将纯学说与没有任何数据网格捆绑包的纯SQL连接时,奇怪的别名就消失了。但是如果我使用任何捆绑包,问题仍然存在。

已解决:我知道这个错误会很简单。创建用户实体时,我给出的表名是[TSOFT_LEARN].[dbo].[User]。教义以某种方式采用了这个名字并将其转换为"[0_"一旦我摆脱了那些"[]",一切都很好。

相关内容

  • 没有找到相关文章

最新更新