32
1
mirror of https://github.com/joomla-extensions/weblinks.git synced 2025-01-27 14:28:30 +00:00

Fix prepared statement, we need different parameters to bind same value :(

This commit is contained in:
Tuan Pham Ngoc 2021-07-17 17:40:29 +07:00
parent 8b9d34ca7d
commit 226e81f7ab
3 changed files with 16 additions and 11 deletions

View File

@ -251,8 +251,9 @@ class WeblinksModel extends ListModel
else
{
$search = '%' . str_replace(' ', '%', $db->escape(trim($search), true) . '%');
$query->where('(' . $db->quoteName('a.title') . ' LIKE :search OR ' . $db->quoteName('a.alias') . ' LIKE :search)')
->bind(':search', $search);
$query->where('(' . $db->quoteName('a.title') . ' LIKE :title OR ' . $db->quoteName('a.alias') . ' LIKE :alias)')
->bind(':title', $search)
->bind(':alias', $search);
}
}

View File

@ -175,10 +175,12 @@ class CategoryModel extends ListModel
{
$nullDate = $db->getNullDate();
$nowDate = Factory::getDate()->toSql();
$query->where('(a.publish_up = :nullDate OR a.publish_up <= :nowDate)')
->where('(a.publish_down = :nullDate OR a.publish_down >= :nowDate)')
->bind(':nullDate', $nullDate)
->bind(':nowDate', $nowDate);
$query->where('(a.publish_up = :publishUpNullDate OR a.publish_up <= :publishUpNowDate)')
->where('(a.publish_down = :publishDownNullDate OR a.publish_down >= :publishDownNowDate)')
->bind(':publishUpNullDate', $nullDate)
->bind(':publishDownNullDate', $nullDate)
->bind(':publishUpNowDate', $nowDate)
->bind(':publishDownNowDate', $nowDate);
}
// Filter by language

View File

@ -91,7 +91,7 @@ class WeblinkModel extends ItemModel
$query = $db->getQuery(true)
->select($this->getState('item.select', 'a.*'))
->from('#__weblinks AS a')
->where($db->quoteName('id') . ' = :id')
->where($db->quoteName('a.id') . ' = :id')
->bind(':id', $pk, ParameterType::INTEGER);
// Join on category table.
@ -119,10 +119,12 @@ class WeblinkModel extends ItemModel
$nullDate = $db->getNullDate();
$nowDate = Factory::getDate()->toSql();
$query->where('(a.publish_up = :nullDate OR a.publish_up <= :nowDate)')
->where('(a.publish_down = :nullDate OR a.publish_down >= :nowDate)')
->bind(':nullDate', $nullDate)
->bind(':nowDate', $nowDate);
$query->where('(a.publish_up = :publishUpNullDate OR a.publish_up <= :publishUpNowDate)')
->where('(a.publish_down = :publishDownNullDate OR a.publish_down >= :publishDownNowDate)')
->bind(':publishUpNullDate', $nullDate)
->bind(':publishDownNullDate', $nullDate)
->bind(':publishUpNowDate', $nowDate)
->bind(':publishDownNowDate', $nowDate);
}
// Filter by published state.