developer.jelix.org is not used any more and exists only for
history. Post new tickets on the Github account.
developer.jelix.org n'est plus utilisée, et existe uniquement pour son historique. Postez les nouveaux tickets sur le compte github.
developer.jelix.org n'est plus utilisée, et existe uniquement pour son historique. Postez les nouveaux tickets sur le compte github.
Opened 12 years ago
Closed 11 years ago
#976 closed bug (fixed)
Bug dans une methode xml d'un dao sur like quand la property est un int
Reported by: | geekbay | Owned by: | laurentj |
---|---|---|---|
Priority: | normal | Milestone: | Jelix 1.0.11 |
Component: | jelix:dao | Version: | 1.1.3 |
Severity: | critical | Keywords: | |
Cc: | Blocked By: | ||
Blocking: | Documentation needed: | no | |
Hosting Provider: | Php version: |
Description
Voici le bug:
dans mon dao j'ai cette methode
<method name="findByCp" type="selectfirst"> <parameter name="cp" /> <conditions> <like property="ville_cp" expr="$cp" /> </conditions> <order> <orderitem property="ville_id" way="asc" /> </order> </method>
cette fonction est compile de la maniere suivante
$__query = $this->_selectClause.$this->_fromClause.$this->_whereClause; $__query .=' WHERE `villes`.`ville_cp` '.'LIKE'.intval($cp).' ORDER BY `villes`.`ville_id` asc'; $__rs = $this->_conn->limitQuery($__query,0,1);
ce qui entraine l'erreur suivante:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'LIKE1140 ORDER BY `villes`.`ville_id` asc LIMIT 0,1' at line 1
je precise que si je passe ville_cp en varchar au lieu de int, alors bien sur ca marche et la fonction compile devient:
$__query = $this->_selectClause.$this->_fromClause.$this->_whereClause; $__query .=' WHERE `villes`.`ville_cp` '.'LIKE'.$this->_conn->quote($cp).' ORDER BY `villes`.`ville_id` asc'; $__rs = $this->_conn->limitQuery($__query,0,1);
Change History (4)
comment:1 Changed 12 years ago by laurentj
- Component changed from jelix to jelix:dao
- Milestone set to Jelix 1.0.11
- Resolution set to fixed
- Severity changed from normal to critical
- Status changed from new to closed
comment:2 Changed 12 years ago by geekbay
- Resolution fixed deleted
- Status changed from closed to reopened
Je reprend mon exemple plus haut.
Effectivement ton patch resoud le probleme dans le cas ou je fais $dao->findByCp(75001) par exemple mais si je fais $dao->findByCp('75%') en fait il va transformer ca a cause du intval alors que pourtant ma requete est legitime dans le cas d'un like.
Il faudrait plutot tout le temps quote $cp et pas le faire passer par intval dans le cas d'un like non ?
comment:3 Changed 11 years ago by laurentj
- Owner set to laurentj
- Status changed from reopened to new
comment:4 Changed 11 years ago by laurentj
- Resolution set to fixed
- Status changed from new to closed
Note: See
TracTickets for help on using
tickets.
fixed in trunk+1.0.x+1.1.x