mirror of
https://github.com/Oreolek/ifhub.club.git
synced 2024-07-01 05:55:02 +03:00
Возможность указать условия при ORM запросе: array('level >'=>1,'status !='=>2)
This commit is contained in:
parent
0e48cb6aa9
commit
2313c4bfad
|
@ -132,9 +132,17 @@ class MapperORM extends Mapper {
|
|||
|
||||
|
||||
$sFilterFields='';
|
||||
if (count($aFilterFields)) {
|
||||
$sFilterFields=' and '.implode(' = ? and ',array_keys($aFilterFields)).' = ? ';
|
||||
}
|
||||
|
||||
foreach ($aFilterFields as $k => $v) {
|
||||
$aK=explode(' ',trim($k));
|
||||
$sFieldCurrent=$aK[0];
|
||||
$sConditionCurrent=' = ';
|
||||
if (count($aK)>1) {
|
||||
$sConditionCurrent=" {$aK[1]} ";
|
||||
}
|
||||
$sFilterFields.=" and $sFieldCurrent $sConditionCurrent ? ";
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM ".$sTableName." WHERE 1=1 {$sFilterFields} {$sOrder} {$sLimit} ";
|
||||
$aQueryParams=array_merge(array($sql),array_values($aFilterFields));
|
||||
$aItems=array();
|
||||
|
|
Loading…
Reference in a new issue