小编Mar*_*rez的帖子

symfony2按属性排序对象集合

我有这样的实体:

class Categoria {

    /**
     * @ORM\Id
     * @ORM\Column(type="integer")
     * @ORM\GeneratedValue
     */

    protected $id;

    /** @ORM\Column(type="string", length=100) */
    protected $nom;

    /** @ORM\Column(type="string", length=100) */
    protected $slug;

    /** @ORM\Column(type="decimal", precision=3, scale=0) */
    protected $ordre;

    /** @ORM\Column(type="boolean", nullable=true) */
    protected $actiu=FALSE;

    /** @ORM\Column(type="decimal", precision=4, scale=0, nullable=true) */
    protected $enllaç=null;

    /** @ORM\OneToMany(targetEntity="LoPati\MenuBundle\Entity\subCategoria", mappedBy="categoria", cascade={"persist", "remove"} )*/
     protected $subCategoria; 
public function __construct()
{
    $this->subCategoria = new \Doctrine\Common\Collections\ArrayCollection();

}

/**
 * Add subCategoria
 *
 * @param LoPati\MenuBundle\Entity\subCategoria $subCategoria
 */
public function addsubCategoria(\LoPati\MenuBundle\Entity\subCategoria $subCategoria)
{
    $this->subCategoria[] …
Run Code Online (Sandbox Code Playgroud)

symfony doctrine-orm twig

7
推荐指数
1
解决办法
1万
查看次数

带有ids的数组的doctrine2顺序

如何通过带有id的数组使用doctrine2命令?

我有这个问题:

$qb = $this->createQueryBuilder('u')
        ->select('u', 'n', 'c')
        ->leftJoin('u.notifications', 'n')
        ->leftJoin('u.channel', 'c')
        ->andWhere('u.id IN (:ids)')
        ->setParameter('ids', $ids);
Run Code Online (Sandbox Code Playgroud)

我希望结果与带有id的数组具有相同的顺序,是否可以这样做?

谢谢

解:

使用FIELD mysql扩展与https://github.com/beberlei/DoctrineExtensions

:)

谢谢

doctrine-query symfony doctrine-orm doctrine-odm

5
推荐指数
2
解决办法
2767
查看次数

角度等待资源删除响应更新列表?

我正在使用$resource添加/删除列表.问题是删除后我仍然看到有时删除元素.

我怎么解决它?

这是代码:

services.js

var services = angular.module('cliConsApp.services', ['ngResource']);

services.factory('IndustrialistsFactory', function ($resource) {
    return $resource(
        '/app_dev.php/api/v1/constructionprivateinformations/:id/industrialists',
        {id: '@id'},
        {
            query: { method: 'GET', isArray: true },
            create: { method: 'POST'}
        }
    )
});

services.factory('IndustrialistFactory', function ($resource) {
    return $resource(
        '/app_dev.php/api/v1/constructionprivateinformations/:id/industrialists/:industrialistId',
        {id: '@id', industrialistId:'@industrialistId'},
        {
        delete: { method: 'DELETE', params: {id: '@id'} }
        }
    )
});
Run Code Online (Sandbox Code Playgroud)

controllers.js

app.controller('industrialistCtrl', ['$scope', 'IndustrialistsFactory', 'IndustrialistFactory',

function ($scope, IndustrialistsFactory, IndustrialistFactory) {

        $scope.createNewUser = function (id) {
            IndustrialistsFactory.create({id: id},$scope.industrialist);

            $scope.industrialists= IndustrialistsFactory.query({},{id: id });

        }

        $scope.deleteUser …
Run Code Online (Sandbox Code Playgroud)

data-binding angularjs angular-resource angularjs-scope

1
推荐指数
1
解决办法
3975
查看次数

角度订单下拉列表选择列表

如何使用Angular在选择下拉列表中订购列表?

这是角度控制器:

var app = angular.module("app", []);

app.controller('Ctrl', function($scope, $filter, $http) {

    $scope.options= [
                  {
                    "id": 823,
                    "value": "81"
                  },
                  {
                    "id": 824,
                    "value": "77"
                  },
                  {
                    "id": 825,
                    "value": "152"
                  },         
                ];   

    });
Run Code Online (Sandbox Code Playgroud)

和HTML:

<h4>Angular-xeditable Editable row (Bootstrap 3)</h4>
<div ng-app="app" ng-controller="Ctrl">    
   <select ng-model="test" ng-options="v.id as v.value for v in options | orderBy: value"></select>
</div>
Run Code Online (Sandbox Code Playgroud)

现在订单是:81,77,152

我想要:77,81,152

我怎么能这样做?

Jsfiddle测试

谢谢

angularjs

1
推荐指数
1
解决办法
5705
查看次数