forked from GithubBackups/tinyib
Update flatfile constructors for PHP7 compatibility - fixes #23
This commit is contained in:
parent
f84085c07e
commit
4c1764b861
@ -76,10 +76,16 @@ class Flatfile {
|
|||||||
*/
|
*/
|
||||||
var $datadir;
|
var $datadir;
|
||||||
|
|
||||||
function Flatfile() {
|
function __construct() {
|
||||||
$this->schemata = array();
|
$this->schemata = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function Flatfile() {
|
||||||
|
if (version_compare(PHP_VERSION, '5.0.0', '<')) {
|
||||||
|
$this->__construct();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all rows from a table
|
* Get all rows from a table
|
||||||
* @param string $tablename The table to get rows from
|
* @param string $tablename The table to get rows from
|
||||||
@ -427,10 +433,16 @@ class NotWhere extends WhereClause {
|
|||||||
* of the WhereClause object passed in when testing rows.
|
* of the WhereClause object passed in when testing rows.
|
||||||
* @param WhereClause $whereclause The WhereClause object to negate
|
* @param WhereClause $whereclause The WhereClause object to negate
|
||||||
*/
|
*/
|
||||||
function NotWhere($whereclause) {
|
function __construct($whereclause) {
|
||||||
$this->clause = $whereclause;
|
$this->clause = $whereclause;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function NotWhere($whereclause) {
|
||||||
|
if (version_compare(PHP_VERSION, '5.0.0', '<')) {
|
||||||
|
$this->__construct($whereclause);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function testRow($row, $rowSchema = null) {
|
function testRow($row, $rowSchema = null) {
|
||||||
return !$this->clause->testRow($row, $rowSchema);
|
return !$this->clause->testRow($row, $rowSchema);
|
||||||
}
|
}
|
||||||
@ -480,13 +492,19 @@ class SimpleWhereClause extends WhereClause {
|
|||||||
* STRING_COMPARISON (default), NUMERIC COMPARISON or INTEGER_COMPARISON
|
* STRING_COMPARISON (default), NUMERIC COMPARISON or INTEGER_COMPARISON
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function SimpleWhereClause($field, $operator, $value, $compare_type = DEFAULT_COMPARISON) {
|
function __construct($field, $operator, $value, $compare_type = DEFAULT_COMPARISON) {
|
||||||
$this->field = $field;
|
$this->field = $field;
|
||||||
$this->operator = $operator;
|
$this->operator = $operator;
|
||||||
$this->value = $value;
|
$this->value = $value;
|
||||||
$this->compare_type = $compare_type;
|
$this->compare_type = $compare_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function SimpleWhereClause($field, $operator, $value, $compare_type = DEFAULT_COMPARISON) {
|
||||||
|
if (version_compare(PHP_VERSION, '5.0.0', '<')) {
|
||||||
|
$this->__construct($field, $operator, $value, $compare_type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function testRow($tablerow, $rowSchema = null) {
|
function testRow($tablerow, $rowSchema = null) {
|
||||||
if ($this->field < 0)
|
if ($this->field < 0)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -536,11 +554,17 @@ class LikeWhereClause extends WhereClause {
|
|||||||
* wildcard, and is case insensitve. e.g. 'test%' will match 'TESTS' and 'Testing'
|
* wildcard, and is case insensitve. e.g. 'test%' will match 'TESTS' and 'Testing'
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function LikeWhereClause($field, $value) {
|
function __construct($field, $value) {
|
||||||
$this->field = $field;
|
$this->field = $field;
|
||||||
$this->regexp = '/^' . str_replace('%', '.*', preg_quote($value)) . '$/i';
|
$this->regexp = '/^' . str_replace('%', '.*', preg_quote($value)) . '$/i';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function LikeWhereClause($field, $value) {
|
||||||
|
if (version_compare(PHP_VERSION, '5.0.0', '<')) {
|
||||||
|
$this->__construct($field, $value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function testRow($tablerow, $rowSchema = NULL) {
|
function testRow($tablerow, $rowSchema = NULL) {
|
||||||
return preg_match($this->regexp, $tablerow[$this->field]);
|
return preg_match($this->regexp, $tablerow[$this->field]);
|
||||||
}
|
}
|
||||||
@ -570,12 +594,18 @@ class ListWhereClause extends WhereClause {
|
|||||||
* @param array $list List of items
|
* @param array $list List of items
|
||||||
* @param string $compare_type Comparison type, string by default.
|
* @param string $compare_type Comparison type, string by default.
|
||||||
*/
|
*/
|
||||||
function ListWhereClause($field, $list, $compare_type = DEFAULT_COMPARISON) {
|
function __construct($field, $list, $compare_type = DEFAULT_COMPARISON) {
|
||||||
$this->list = $list;
|
$this->list = $list;
|
||||||
$this->field = (int)$field;
|
$this->field = (int)$field;
|
||||||
$this->compareAs = $compare_type;
|
$this->compareAs = $compare_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function ListWhereClause($field, $list, $compare_type = DEFAULT_COMPARISON) {
|
||||||
|
if (version_compare(PHP_VERSION, '5.0.0', '<')) {
|
||||||
|
$this->__construct($field, $list, $compare_type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function testRow($tablerow, $rowSchema = null) {
|
function testRow($tablerow, $rowSchema = null) {
|
||||||
$func = $this->compareAs;
|
$func = $this->compareAs;
|
||||||
if ($func == DEFAULT_COMPARISON) {
|
if ($func == DEFAULT_COMPARISON) {
|
||||||
@ -639,9 +669,15 @@ class OrWhereClause extends CompositeWhereClause {
|
|||||||
* Creates a new OrWhereClause
|
* Creates a new OrWhereClause
|
||||||
* @param WhereClause $whereClause,... optional unlimited list of WhereClause objects to be added
|
* @param WhereClause $whereClause,... optional unlimited list of WhereClause objects to be added
|
||||||
*/
|
*/
|
||||||
function OrWhereClause() {
|
function __construct() {
|
||||||
$this->clauses = func_get_args();
|
$this->clauses = func_get_args();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function OrWhereClause() {
|
||||||
|
if (version_compare(PHP_VERSION, '5.0.0', '<')) {
|
||||||
|
$this->__construct();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -667,9 +703,15 @@ class AndWhereClause extends CompositeWhereClause {
|
|||||||
* Creates a new AndWhereClause
|
* Creates a new AndWhereClause
|
||||||
* @param WhereClause $whereClause,... optional unlimited list of WhereClause objects to be added
|
* @param WhereClause $whereClause,... optional unlimited list of WhereClause objects to be added
|
||||||
*/
|
*/
|
||||||
function AndWhereClause() {
|
function __construct() {
|
||||||
$this->clauses = func_get_args();
|
$this->clauses = func_get_args();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function AndWhereClause() {
|
||||||
|
if (version_compare(PHP_VERSION, '5.0.0', '<')) {
|
||||||
|
$this->__construct();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -701,11 +743,17 @@ class OrderBy {
|
|||||||
* @param int $compareAs Comparison type: DEFAULT_COMPARISON, STRING_COMPARISON, INTEGER_COMPARISION,
|
* @param int $compareAs Comparison type: DEFAULT_COMPARISON, STRING_COMPARISON, INTEGER_COMPARISION,
|
||||||
* or NUMERIC_COMPARISON, or the name of a user defined function that you want to use for doing the comparison.
|
* or NUMERIC_COMPARISON, or the name of a user defined function that you want to use for doing the comparison.
|
||||||
*/
|
*/
|
||||||
function OrderBy($field, $orderType, $compareAs = DEFAULT_COMPARISON) {
|
function __construct($field, $orderType, $compareAs = DEFAULT_COMPARISON) {
|
||||||
$this->field = $field;
|
$this->field = $field;
|
||||||
$this->orderType = $orderType;
|
$this->orderType = $orderType;
|
||||||
$this->compareAs = $compareAs;
|
$this->compareAs = $compareAs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function OrderBy($field, $orderType, $compareAs) {
|
||||||
|
if (version_compare(PHP_VERSION, '5.0.0', '<')) {
|
||||||
|
$this->__construct();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -726,7 +774,7 @@ class Orderer {
|
|||||||
* @param mixed $orderBy An OrderBy object or an array of them
|
* @param mixed $orderBy An OrderBy object or an array of them
|
||||||
* @param array $rowSchema Option row schema
|
* @param array $rowSchema Option row schema
|
||||||
*/
|
*/
|
||||||
function Orderer($orderBy, $rowSchema = null) {
|
function __construct($orderBy, $rowSchema = null) {
|
||||||
if (!is_array($orderBy))
|
if (!is_array($orderBy))
|
||||||
$orderBy = array($orderBy);
|
$orderBy = array($orderBy);
|
||||||
if ($rowSchema) {
|
if ($rowSchema) {
|
||||||
@ -741,6 +789,12 @@ class Orderer {
|
|||||||
$this->orderByList = $orderBy;
|
$this->orderByList = $orderBy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function Orderer($orderBy, $rowSchema = null) {
|
||||||
|
if (version_compare(PHP_VERSION, '5.0.0', '<')) {
|
||||||
|
$this->__construct($orderBy, $rowSchema);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compares two table rows using the comparisons defined by the OrderBy
|
* Compares two table rows using the comparisons defined by the OrderBy
|
||||||
* objects. This function is of the type that can be used passed to usort().
|
* objects. This function is of the type that can be used passed to usort().
|
||||||
|
@ -17,19 +17,31 @@ class Column {
|
|||||||
/**
|
/**
|
||||||
* Create a new column object
|
* Create a new column object
|
||||||
*/
|
*/
|
||||||
function Column($index, $type) {
|
function __construct($index, $type) {
|
||||||
$this->index = $index;
|
$this->index = $index;
|
||||||
$this->type = $type;
|
$this->type = $type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function Column($index, $type) {
|
||||||
|
if (version_compare(PHP_VERSION, '5.0.0', '<')) {
|
||||||
|
$this->__construct($index, $type);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** EXPERIMENTAL: Represent a column that is a foreign key. Used for temporarily building tables array */
|
/** EXPERIMENTAL: Represent a column that is a foreign key. Used for temporarily building tables array */
|
||||||
class JoinColumn {
|
class JoinColumn {
|
||||||
function JoinColumn($index, $tablename, $columnname) {
|
function __construct($index, $tablename, $columnname) {
|
||||||
$this->index = $index;
|
$this->index = $index;
|
||||||
$this->tablename = $tablename;
|
$this->tablename = $tablename;
|
||||||
$this->columnname = $columnname;
|
$this->columnname = $columnname;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function JoinColumn($index, $tablename, $columnname) {
|
||||||
|
if (version_compare(PHP_VERSION, '5.0.0', '<')) {
|
||||||
|
$this->__construct($index, $tablename, $columnname);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user