Skip to content

Commit

Permalink
Dev: Restore dbExecuteAssoc since it's still used
Browse files Browse the repository at this point in the history
  • Loading branch information
olleharstedt committed Aug 12, 2021
1 parent 2bf863b commit 77f8422
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions application/helpers/database_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,37 @@
*
*/

/**
*
* @param string $sql
* @param array|bool $inputarr
* @param boolean $silent
* @return bool|CDbDataReader
* @throws Exception
* @deprecated Do not use anymore. If you see this replace it with a proper ActiveRecord Model query
*/
function dbExecuteAssoc($sql, $inputarr = false, $silent = true)
{
$error = '';
try {
if ($inputarr) {
$dataset = Yii::app()->db->createCommand($sql)->bindValues($inputarr)->query(); //Checked
} else {
$dataset = Yii::app()->db->createCommand($sql)->query();

}
} catch (CDbException $e) {
$error = $e->getMessage();
$dataset = false;
}

if (!$dataset && (Yii::app()->getConfig('debug') > 0 || !$silent)) {
// Exception is better than safeDie, because you can see the backtrace.
throw new \Exception('Error executing query in dbExecuteAssoc:'.$error);
}
return $dataset;
}

/**
* Return the database-specific random function to use in ORDER BY sql statements
*
Expand Down

0 comments on commit 77f8422

Please sign in to comment.