Skip to content

Instantly share code, notes, and snippets.

@DBasic
Forked from stden/SP.php
Created March 8, 2014 17:45
Show Gist options
  • Save DBasic/9435732 to your computer and use it in GitHub Desktop.
Save DBasic/9435732 to your computer and use it in GitHub Desktop.
/**
* @static Вызов хранимой процедуры
* @param $sp_name Название хранимой процедуры
* @param $params
* @return array
*/
public static function Query($sp_name, $params)
{
// Получаем CommandBuilder
$b = Yii::app()->db->getCommandBuilder();
// Создаём команду
$pars = implode(',', array_keys($params));
$cmd = $b->createSqlCommand("CALL $sp_name($pars)", $params);
// Получаем все записи
return $cmd->queryAll();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment