Bonjour
Voila aujourd'hui et après avoir réussi a faire la pagination dans ma page index je m'aperçois après que l'ajout ne marche plu et quand je clic sur ajouté il m'affiche une erreur qui dit:
Bon j'explique les seul changement que j'ai effectué pour la pagination :CRITICAL - Uncaught PHP Exception Doctrine\DBAL\DBALException: "LIMIT argument offset=-4 is not valid" at C:\wamp\www\Livraison\vendor\doctrine\dbal\lib\Doctrine\DBAL\Platforms\AbstractPlatform.php line 2668"
Dans Mon Routing j'ai changer l'index dans client.yml qui est devenu comme ceci:
Dans Mon Contrôleur j'ai changer IndexAction() qui est devenu comme ceci:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3 client: pattern: /{page} defaults: { _controller: "SLamaLivraisonBundle:Client:index", page: 1 }
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 public function indexAction($page) { $session = new Session(); if ($session->get('valid')=='true') { $client=new Client(); $form = $this->container->get('form.factory')->create(new ClientType()); $total = $this->getDoctrine()->getRepository('SLamaLivraisonBundle:Client')->createQueryBuilder('p')->getQuery()->getResult(); /* total of résultat */ $total_clients = count($total); $clients_per_page = 4; $last_page = ceil($total_clients / $clients_per_page); $previous_page = $page > 1 ? $page - 1 : 1; $next_page = $page < $last_page ? $page + 1 : $last_page; /* résultat à afficher*/ $entities = $this->getDoctrine()->getRepository('SLamaLivraisonBundle:Client')->createQueryBuilder('p')->setFirstResult(($page * $clients_per_page) - $clients_per_page)->setMaxResults(4)->getQuery()->getResult(); return $this->render('SLamaLivraisonBundle:Client:index.html.twig', array( 'entities' => $entities, 'last_page' => $last_page, 'previous_page' => $previous_page, 'current_page' => $page, 'next_page' => $next_page, 'total_clients' => $total_clients, 'form' => $form->createView(), 'client'=>$client, )); return $this->render('SLamaLivraisonBundle:Client:index.html.twig'); } else return $this->redirect($this->generateUrl('Admin')); }
Et Dans le Twig j'ai tout changer presque et voila mon code
Quelqu'un Peu M'aidai SVP car j'ai Rien Changer dans NewAction et ca marche plu en plus je c pas ce que veu dire cette erreur
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72 <h4 class="alert_info">Welcome to the Client List Manager.</h4> <article class="module width_3_quarter"> <header><h3 class="tabs_involved">Client list Manager</h3> <ul class="tabs"> <a href="{{ path('client_new') }}"><img src="{{ asset('bundles/Livraison/images/add26.png') }}" title="Create a new entry"/></a> </ul> </header> <div class="tab_container"> <div id="tab1" class="tab_content"> {% if entities is not empty %} <table class="tablesorter" cellspacing="0"> <thead> <tr> <th>Id</th> <th>Nom</th> <th>Prenom</th> <th>Adresse</th> <th>Code Postal</th> <th>Numéro Téléléphone</th> <th>Email</th> <th>Cin</th> <th>Actions</th> </tr> </thead> <tbody> {% for key, entity in entities %} <tr> <td><a href="{{ path('client_show', { 'id': entity.id }) }}">{{ entity.id }}</a></td> <td>{{ entity.nom }}</td> <td>{{ entity.prenom }}</td> <td>{{ entity.adresse }}</td> <td>{{ entity.codepostal }}</td> <td>{{ entity.tel }}</td> <td>{{ entity.email }}</td> <td>{{ entity.cin }}</td> <td> <a href="{{ path('client_show', { 'id': entity.id }) }}"><img src="{{ asset('bundles/Livraison/images/info20.png') }}" title="Show"/></a> <a href="{{ path('client_edit', { 'id': entity.id }) }}"><img src="{{ asset('bundles/Livraison/images/edit20.png') }}" title="Edit"/></a> </td> </tr> {% endfor %} </tbody> </table> {% else %} <p>Résultat vide</p> {% endif %} <table class="tablesorter" cellspacing="0"> <thead> <tr> <th><span></span></th> <th><span></span></th> {% if last_page > 1 %} <th><a href="{{ path('client', { 'page': 1 }) }}"> <span> prec </span> </a></th><th> <a href="{{ path('client', { 'page': previous_page }) }}"> <span> prec </span> </a></th> <th><a href="{{ path('client', { 'page': next_page }) }}"> <span> suiv </span> </a></th><th> <a href="{{ path('client', { 'page': last_page }) }}"> <span> suiv </span></a></th> {% endif %} </tr> </thead></table> </div><!-- end of #tab1 --> </div><!-- end of .tab_container --> </article><!-- end of content manager article -->
Merci et Désolé pour le dérangement
Partager