Skip to content

Commit

Permalink
converted to php 5.3 syntax using https://github.com/endel/php-code-d…
Browse files Browse the repository at this point in the history
  • Loading branch information
mfurlend authored and Arbuzov committed May 5, 2016
1 parent a4e6be7 commit 1f44e0d
Show file tree
Hide file tree
Showing 17 changed files with 727 additions and 838 deletions.
2 changes: 1 addition & 1 deletion init.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<?php

require __DIR__ . '/vendor/autoload.php';
require __DIR__.'/vendor/autoload.php';
16 changes: 8 additions & 8 deletions lib/AbstractController.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

abstract class AbstractController
{
protected $db = null;
protected $args = [];
protected $db = null;
protected $args = array();

function __construct($db = null, $args = [])
{
$this->db = $db;
$this->args = $args;
}
function __construct($db = null, $args = array())
{
$this->db = $db;
$this->args = $args;
}

abstract public function runStrategy();
public abstract function runStrategy();
}
142 changes: 67 additions & 75 deletions lib/AbstractMigration.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,70 +8,7 @@ abstract class AbstractMigration
*/
protected $db;

/**
* Build list of sql queries for the up event
*/
protected function buildUp()
{
return isset($this->up) ? $this->up : [];
}

/**
* Build list of sql queries for the preup event
*/
protected function buildPreup()
{
return isset($this->preup) ? $this->preup : [];
}

/**
* Build list of sql queries for the postup event
*/
protected function buildPostup()
{
return isset($this->postup) ? $this->postup : [];
}

/**
* Build list of sql queries for the down event
*/
protected function buildDown()
{
return isset($this->down) ? $this->down : [];
}

/**
* Build list of sql queries for the predown event
*/
protected function buildPredown()
{
return isset($this->predown) ? $this->predown : [];
}

/**
* Build list of sql queries for the postdown event
*/
protected function buildPostdown()
{
return isset($this->postdown) ? $this->postdown : [];
}

/**
* Get current revision number
*/
protected function getRev()
{
return isset($this->rev) ? $this->rev : 0;
}
/**
* Get current alias
*/
protected function getAlias()
{
return (Helper::get('aliasprefix') ?: '') . (string) (isset($this->alias) ? $this->alias : 0);
}

public function __construct(mysqli $db)
public function __construct(mysqli $db)
{
$this->db = $db;
}
Expand All @@ -84,37 +21,64 @@ public function runUp()
foreach ($this->buildPreup() as $query) {
Output::verbose('PREUP: '.$query);
if ($this->db->query($query)) {
Output::verbose("Ok");
Output::verbose('Ok');
} else {
Output::verbose($this->db->error);
}
}

foreach ($this->buildUp() as $query) {
Output::verbose('UP: '.$query);
if ($this->db->query($query)) {
Output::verbose("Ok");
Output::verbose('Ok');
} else {
Output::verbose($this->db->error);
}
}

foreach ($this->buildPostup() as $query) {
Output::verbose('POSTUP: '.$query);
if ($this->db->query($query)) {
Output::verbose("Ok");
Output::verbose('Ok');
} else {
Output::verbose($this->db->error);
}
}

$verT = Helper::get('versiontable');
$rev = $this->getRev();
$query = "INSERT INTO `{$verT}` SET `rev`={$rev}";
Output::verbose($query);
$this->db->query($query);
}

/**
* Build list of sql queries for the preup event
*/
protected function buildPreup()
{
return isset($this->preup) ? $this->preup : array();
}

/**
* Build list of sql queries for the up event
*/
protected function buildUp()
{
return isset($this->up) ? $this->up : array();
}

/**
* Build list of sql queries for the postup event
*/
protected function buildPostup()
{
return isset($this->postup) ? $this->postup : array();
}

/**
* Get current revision number
*/
protected function getRev()
{
return isset($this->rev) ? $this->rev : 0;
}

/**
Expand All @@ -125,31 +89,59 @@ public function runDown()
foreach ($this->buildPredown() as $query) {
Output::verbose('PREDOWN: '.$query);
if ($this->db->query($query)) {
Output::verbose("Ok");
Output::verbose('Ok');
} else {
Output::verbose($this->db->error);
}
}

foreach ($this->buildDown() as $query) {
Output::verbose('DOWN:'.$query);
$this->db->query($query);
}

foreach ($this->buildPostdown() as $query) {
Output::verbose('POSTDOWN: '.$query);
if ($this->db->query($query)) {
Output::verbose("Ok");
Output::verbose('Ok');
} else {
Output::verbose($this->db->error);
}
}

$verT = Helper::get('versiontable');
$rev = $this->getRev();
$query = "DELETE FROM `{$verT}` WHERE `rev`={$rev}";
Output::verbose($query);
$this->db->query($query);
}

/**
* Build list of sql queries for the predown event
*/
protected function buildPredown()
{
return isset($this->predown) ? $this->predown : array();
}

/**
* Build list of sql queries for the down event
*/
protected function buildDown()
{
return isset($this->down) ? $this->down : array();
}

/**
* Build list of sql queries for the postdown event
*/
protected function buildPostdown()
{
return isset($this->postdown) ? $this->postdown : array();
}

/**
* Get current alias
*/
protected function getAlias()
{
return (Helper::get('aliasprefix') ?: '').(string)(isset($this->alias) ? $this->alias : 0);
}
}
10 changes: 4 additions & 6 deletions lib/AbstractSchema.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@

abstract class AbstractSchema
{

protected function buildQueries()
{
return isset($this->queries) ? $this->queries : [];
}

public function load(Mysqli $db)
{
foreach ($this->buildQueries() as $query) {
Expand All @@ -18,4 +12,8 @@ public function load(Mysqli $db)
}
}

protected function buildQueries()
{
return isset($this->queries) ? $this->queries : array();
}
}
Loading

0 comments on commit 1f44e0d

Please sign in to comment.