Skip to content

Instantly share code, notes, and snippets.

@cornernote
Created November 22, 2012 02:06
Show Gist options
  • Select an option

  • Save cornernote/4129035 to your computer and use it in GitHub Desktop.

Select an option

Save cornernote/4129035 to your computer and use it in GitHub Desktop.
<?php
/**
* DbMigration
*
* @author Brett O'Donnell <brett@mrphp.com.au>
*/
class DbMigration extends CDbMigration
{
/**
* @param $sql
* @return integer number of rows affected by the execution.
*/
protected function q($sql)
{
return $this->dbConnection->createCommand($sql)->execute();
}
/**
* @param $sql
* @param string $separator
* @return array of numbers of rows affected by the executions.
*/
protected function qs($sql, $separator = ';')
{
$rs = array();
$qs = explode($separator, $sql);
foreach ($qs as $q) {
if (trim($q)) {
$rs[] = $this->q($q);
}
}
return $rs;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment