summaryrefslogtreecommitdiff
path: root/app/php/db/ActiveRecord.php
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2016-06-07 15:17:49 +0200
committeremkael <emkael@tlen.pl>2016-06-10 11:46:41 +0200
commit823d71ced9b4947b1a5a5ade7245d521ed490061 (patch)
treea9a6c7cb0de74ff705e8320c284de423a698f5b5 /app/php/db/ActiveRecord.php
parentdf401552aac363655ab8f056a6c910a7611954d6 (diff)
* renaming php directory
Diffstat (limited to 'app/php/db/ActiveRecord.php')
-rw-r--r--app/php/db/ActiveRecord.php69
1 files changed, 0 insertions, 69 deletions
diff --git a/app/php/db/ActiveRecord.php b/app/php/db/ActiveRecord.php
deleted file mode 100644
index 1176767..0000000
--- a/app/php/db/ActiveRecord.php
+++ /dev/null
@@ -1,69 +0,0 @@
-<?php
-
-class ActiveRecord extends TActiveRecord {
-
- private function _getMappedPropertyName($name) {
- if (isset(static::$COLUMN_MAPPING[$name])) {
- return static::$COLUMN_MAPPING[$name];
- }
- return $name;
- }
-
- const DYNAMIC_METHODS = [
- 'findby',
- 'findallby',
- 'deleteby',
- 'deleteallby'
- ];
-
- private function _getMappedMethodName($method) {
- if (static::$COLUMN_MAPPING) {
- $methodParts = [];
- if (preg_match('/^(' . implode('|', self::DYNAMIC_METHODS) . ')(.*)$/i', $method, $methodParts)) {
- $methodParameters = [];
- $columnString = implode(
- '|',
- array_merge(
- array_keys(static::$COLUMN_MAPPING),
- array_values(static::$COLUMN_MAPPING)
- )
- );
- $parameterRegex = '/(' . $columnString . ')(and|_and_|or|_or_)?/i';
- $method = $methodParts[1];
- if (preg_match_all($parameterRegex, $methodParts[2], $methodParameters, PREG_SET_ORDER)) {
- foreach ($methodParameters as $parameter) {
- $mappedColumn = array_search($parameter[1], static::$COLUMN_MAPPING);
- $method .= ($mappedColumn !== FALSE) ? $mappedColumn : $parameter[1];
- if (count($parameter) > 2) {
- $method .= $parameter[2];
- }
- }
- }
- }
- }
- return $method;
- }
-
- public function __get($name) {
- $name = $this->_getMappedPropertyName($name);
- if (property_exists($this, $name)) {
- return $this->$name;
- }
- return parent::__get($name);
- }
-
- public function __set($name, $value) {
- $name = $this->_getMappedPropertyName($name);
- if (property_exists($this, $name)) {
- return $this->$name = $value;
- }
- return parent::__set($name, $value);
- }
-
- public function __call($method, $args) {
- return parent::__call($this->_getMappedMethodName($method), $args);
- }
-
-}
-
-?>