Kpn_paginator - Platform mysql does not support offset values in limit queries
Bonjour,
j'ai utilisé le Kpn_paginator en suivant le tuto grafikart
je comprends grossièrement ce que je fait mais je n'ai que 8h de symfony...
Dans mon projet d'apprentissage, sur lequel je suis connecté en local sur une base MySql (MAMP) pas de problème tout fonctionne
je souhaite désormais l'implémenter sur mon projet qui interroge une base sql server
la page s'affiche correctement (5 premiers musiciens et barre de pagination)
mais lorsque je click sur les liens de barre de pagination j’obtiens une erreur très curieuse qui mentionne mysql ???
d'avance merci pour votre aide
Musicien.php
Code:
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 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183
| <?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Musicien
*
* @ORM\Table(name="Musicien", indexes={@ORM\Index(name="IDX_AC6BE67520B77BF2", columns={"Code_Pays"}), @ORM\Index(name="IDX_AC6BE675E1990660", columns={"Code_Genre"}), @ORM\Index(name="IDX_AC6BE675D389A975", columns={"Code_Instrument"})})
* @ORM\Entity
* @ORM\Entity(repositoryClass="App\Repository\MusicienRepository")
*/
class Musicien
{
/**
* @var int
*
* @ORM\Column(name="Code_Musicien", type="integer", nullable=false)
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $codeMusicien;
/**
* @var string
*
* @ORM\Column(name="Nom_Musicien", type="string", length=200, nullable=false)
*/
private $nomMusicien;
/**
* @var string|null
*
* @ORM\Column(name="Prenom_Musicien", type="string", length=50, nullable=true)
*/
private $prenomMusicien;
/**
* @var int|null
*
* @ORM\Column(name="Annee_Naissance", type="integer", nullable=true)
*/
private $anneeNaissance;
/**
* @var int|null
*
* @ORM\Column(name="Annee_Mort", type="integer", nullable=true)
*/
private $anneeMort;
/**
* @var binary|null
*
* @ORM\Column(name="Photo", type="binary", nullable=true)
*/
private $photo;
/**
* @var \Genre
*
* @ORM\ManyToOne(targetEntity="Genre")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="Code_Genre", referencedColumnName="Code_Genre")
* })
*/
private $codeGenre;
/**
* @var \Instrument
*
* @ORM\ManyToOne(targetEntity="Instrument")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="Code_Instrument", referencedColumnName="Code_Instrument")
* })
*/
private $codeInstrument;
public function getCodeMusicien(): ?int
{
return $this->codeMusicien;
}
public function getNomMusicien(): ?string
{
return $this->nomMusicien;
}
public function setNomMusicien(string $nomMusicien): self
{
$this->nomMusicien = $nomMusicien;
return $this;
}
public function getPrenomMusicien(): ?string
{
return $this->prenomMusicien;
}
public function setPrenomMusicien(?string $prenomMusicien): self
{
$this->prenomMusicien = $prenomMusicien;
return $this;
}
public function getAnneeNaissance(): ?int
{
return $this->anneeNaissance;
}
public function setAnneeNaissance(?int $anneeNaissance): self
{
$this->anneeNaissance = $anneeNaissance;
return $this;
}
public function getAnneeMort(): ?int
{
return $this->anneeMort;
}
public function setAnneeMort(?int $anneeMort): self
{
$this->anneeMort = $anneeMort;
return $this;
}
public function getPhoto()
{
return $this->photo;
}
public function setPhoto($photo): self
{
$this->photo = $photo;
return $this;
}
public function getCodePays(): ?Pays
{
return $this->codePays;
}
public function setCodePays(?Pays $codePays): self
{
$this->codePays = $codePays;
return $this;
}
public function getCodeGenre(): ?Genre
{
return $this->codeGenre;
}
public function setCodeGenre(?Genre $codeGenre): self
{
$this->codeGenre = $codeGenre;
return $this;
}
public function getCodeInstrument(): ?Instrument
{
return $this->codeInstrument;
}
public function setCodeInstrument(?Instrument $codeInstrument): self
{
$this->codeInstrument = $codeInstrument;
return $this;
}
} |
MusicienRepository.php
Code:
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
| <?php
namespace App\Repository;
use Doctrine\ORM\Query;
use App\Entity\Musicien;
use Symfony\Bridge\Doctrine\RegistryInterface;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
/**
* @method Musicien|null find($id, $lockMode = null, $lockVersion = null)
* @method Musicien|null findOneBy(array $criteria, array $orderBy = null)
* @method Musicien[] findAll()
* @method Musicien[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class MusicienRepository extends ServiceEntityRepository
{
public function __construct(RegistryInterface $registry)
{
parent::__construct($registry, Musicien::class);
}
/**
* @return Query
*/
public function findAllMusiciens(){
return $this->createQueryBuilder('m')//'m' est un alias
->getQuery();
}
// /**
// * @return Musicien[] Returns an array of Musicien objects
// */
/*
public function findByExampleField($value)
{
return $this->createQueryBuilder('m')
->andWhere('m.exampleField = :val')
->setParameter('val', $value)
->orderBy('m.id', 'ASC')
->setMaxResults(10)
->getQuery()
->getResult()
;
}
*/
/*
public function findOneBySomeField($value): ?Musicien
{
return $this->createQueryBuilder('m')
->andWhere('m.exampleField = :val')
->setParameter('val', $value)
->getQuery()
->getOneOrNullResult()
;
}
*/
} |
MusicienController.php
Code:
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
| <?php
namespace App\Form;
use App\Entity\Musicien;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
class MusicienType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('nomMusicien')
->add('prenomMusicien')
//->add('anneeNaissance')
//->add('anneeMort')
->add('photo')
//->add('codeGenre')
//->add('codeInstrument')
;
}
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
'data_class' => Musicien::class,
]);
}
} |
index.html.twig
Code:
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
| {% extends 'base.html.twig' %}
{% block title %}Liste des musiciens{% endblock %}
{% block body %}
<div class="jumbotron text-center">
<h1>Liste des musiciens</h1>
</div>
<div class="container">
<table class="table">
<thead>
<tr>
<th>Code</th>
<th>Nom</th>
<th>Prenom</th>
<!--<th>Annee Naissance</th>
<th>Annee Mort</th>-->
<th>Photo</th>
<th>actions</th>
</tr>
</thead>
<tbody>
{% for musicien in musiciens %}
<tr>
<td>{{ musicien.codeMusicien }}</td>
<td>{{ musicien.nomMusicien }}</td>
<td>{{ musicien.prenomMusicien }}</td>
<!--<td>{{ musicien.anneeNaissance }}</td>
<td>{{ musicien.anneeMort }}</td>-->
<td>{{ musicien.photo }}</td>
<td>
<a href="{{ path('musicien_show', {'codeMusicien': musicien.codeMusicien}) }}">Voir</a>
</td>
</tr>
{% else %}
<tr>
<td colspan="7">Aucun musicien correspondant à la recherche</td>
</tr>
{% endfor %}
</tbody>
</table>
<div class="navigation">
{{ knp_pagination_render(musiciens)}}
</div>
</div>
{% endblock %} |
kpn_paginator.yaml
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13
| knp_paginator:
page_range: 5 # number of links showed in the pagination menu (e.g: you have 10 pages, a page_range of 3, on the 5th page you'll see links to page 4, 5, 6)
default_options:
page_name: page # page query parameter name
sort_field_name: sort # sort field query parameter name
sort_direction_name: direction # sort direction query parameter name
distinct: true # ensure distinct results, useful when ORM queries are using GROUP BY statements
filter_field_name: filterField # filter field query parameter name
filter_value_name: filterValue # filter value query parameter name
template:
pagination: '@KnpPaginator/Pagination/twitter_bootstrap_v4_pagination.html.twig' # sliding pagination controls
sortable: '@KnpPaginator/Pagination/sortable_link.html.twig' # sort link template
filtration: '@KnpPaginator/Pagination/filtration.html.twig' # filters template |