|
|
@ -1,19 +1,6 @@
|
|
|
|
<?php
|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Project:
|
|
|
|
|
|
|
|
* Contenido Content Management System
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* Description:
|
|
|
|
|
|
|
|
* Generic database abstraction functions.
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* NOTE:
|
|
|
|
|
|
|
|
* Because of required downwards compatibilitiy all protected/private member
|
|
|
|
|
|
|
|
* variables or methods don't have an leading underscore.
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* Requirements:
|
|
|
|
|
|
|
|
* @con_php_req 5.0
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @package Contenido Backend classes
|
|
|
|
* @package Contenido Backend classes
|
|
|
|
* @version $Id$
|
|
|
|
* @version $Id$
|
|
|
|
* @author Timo A. Hummel
|
|
|
|
* @author Timo A. Hummel
|
|
|
@ -24,7 +11,6 @@
|
|
|
|
* @link http://www.contenido.org
|
|
|
|
* @link http://www.contenido.org
|
|
|
|
* @since file available since contenido release <= 4.6
|
|
|
|
* @since file available since contenido release <= 4.6
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
if (!defined('CON_FRAMEWORK')) {
|
|
|
|
if (!defined('CON_FRAMEWORK')) {
|
|
|
|
die('Illegal call');
|
|
|
|
die('Illegal call');
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -32,7 +18,7 @@ if (!defined('CON_FRAMEWORK')) {
|
|
|
|
global $cfg;
|
|
|
|
global $cfg;
|
|
|
|
|
|
|
|
|
|
|
|
// Try to load GenericDB database driver
|
|
|
|
// Try to load GenericDB database driver
|
|
|
|
$driver_filename = $cfg['path']['contenido'].$cfg['path']['classes'].'drivers/'.$cfg['sql']['gdb_driver'].'/class.gdb.'.$cfg['sql']['gdb_driver'].'.php';
|
|
|
|
$driver_filename = $cfg['path']['contenido'] . $cfg['path']['classes'] . 'drivers/' . $cfg['sql']['gdb_driver'] . '/class.gdb.' . $cfg['sql']['gdb_driver'] . '.php';
|
|
|
|
|
|
|
|
|
|
|
|
if (file_exists($driver_filename)) {
|
|
|
|
if (file_exists($driver_filename)) {
|
|
|
|
include_once($driver_filename);
|
|
|
|
include_once($driver_filename);
|
|
|
@ -42,20 +28,17 @@ if (file_exists($driver_filename)) {
|
|
|
|
cInclude("classes", "genericdb/class.item.base.abstract.php");
|
|
|
|
cInclude("classes", "genericdb/class.item.base.abstract.php");
|
|
|
|
cInclude("classes", "genericdb/class.item.cache.php");
|
|
|
|
cInclude("classes", "genericdb/class.item.cache.php");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Class Contenido_ItemException.
|
|
|
|
* Class Contenido_ItemException.
|
|
|
|
* @author Murat Purc <murat@purc.de>
|
|
|
|
* @author Murat Purc <murat@purc.de>
|
|
|
|
* @version 0.1
|
|
|
|
* @version 0.1
|
|
|
|
* @copyright four for business AG <www.4fb.de>
|
|
|
|
* @copyright four for business AG <www.4fb.de>
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
class Contenido_ItemException extends Exception {}
|
|
|
|
class Contenido_ItemException extends Exception {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Class ItemCollection
|
|
|
|
* Class ItemCollection
|
|
|
|
* Abstract class for database based item collections.
|
|
|
|
* Abstract class for database based item collections.
|
|
|
|
*
|
|
|
|
*
|
|
|
@ -64,8 +47,8 @@ class Contenido_ItemException extends Exception {}
|
|
|
|
* @version 0.2
|
|
|
|
* @version 0.2
|
|
|
|
* @copyright four for business 2003
|
|
|
|
* @copyright four for business 2003
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
abstract class ItemCollection extends cItemBaseAbstract
|
|
|
|
abstract class ItemCollection extends cItemBaseAbstract {
|
|
|
|
{
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Storage of all result items
|
|
|
|
* Storage of all result items
|
|
|
|
* @var string Contains all result items
|
|
|
|
* @var string Contains all result items
|
|
|
@ -78,7 +61,6 @@ abstract class ItemCollection extends cItemBaseAbstract
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
protected $_driver;
|
|
|
|
protected $_driver;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* List of instances of ItemCollection implementations
|
|
|
|
* List of instances of ItemCollection implementations
|
|
|
|
* @var array
|
|
|
|
* @var array
|
|
|
@ -148,7 +130,6 @@ abstract class ItemCollection extends cItemBaseAbstract
|
|
|
|
* @var bool
|
|
|
|
* @var bool
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
protected $_bAllMode = false;
|
|
|
|
protected $_bAllMode = false;
|
|
|
|
|
|
|
|
|
|
|
|
protected $_order;
|
|
|
|
protected $_order;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -158,8 +139,7 @@ abstract class ItemCollection extends cItemBaseAbstract
|
|
|
|
* @param string $sPrimaryKey The primary key to use
|
|
|
|
* @param string $sPrimaryKey The primary key to use
|
|
|
|
* @param int $iLifetime
|
|
|
|
* @param int $iLifetime
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public function __construct($sTable, $sPrimaryKey, $iLifetime = 10)
|
|
|
|
public function __construct($sTable, $sPrimaryKey, $iLifetime = 10) {
|
|
|
|
{
|
|
|
|
|
|
|
|
parent::__construct($sTable, $sPrimaryKey, get_parent_class($this), $iLifetime);
|
|
|
|
parent::__construct($sTable, $sPrimaryKey, get_parent_class($this), $iLifetime);
|
|
|
|
|
|
|
|
|
|
|
|
$this->resetQuery();
|
|
|
|
$this->resetQuery();
|
|
|
@ -187,8 +167,7 @@ abstract class ItemCollection extends cItemBaseAbstract
|
|
|
|
* @param string $sForeignCollectionClass Specifies the foreign class to use
|
|
|
|
* @param string $sForeignCollectionClass Specifies the foreign class to use
|
|
|
|
* @return void
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
protected function _setJoinPartner($sForeignCollectionClass)
|
|
|
|
protected function _setJoinPartner($sForeignCollectionClass) {
|
|
|
|
{
|
|
|
|
|
|
|
|
if (class_exists($sForeignCollectionClass)) {
|
|
|
|
if (class_exists($sForeignCollectionClass)) {
|
|
|
|
// Add class
|
|
|
|
// Add class
|
|
|
|
if (!in_array($sForeignCollectionClass, $this->_JoinPartners)) {
|
|
|
|
if (!in_array($sForeignCollectionClass, $this->_JoinPartners)) {
|
|
|
@ -207,8 +186,7 @@ abstract class ItemCollection extends cItemBaseAbstract
|
|
|
|
* @param string $sClassName Specifies the classname of item
|
|
|
|
* @param string $sClassName Specifies the classname of item
|
|
|
|
* @return void
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
protected function _setItemClass($sClassName)
|
|
|
|
protected function _setItemClass($sClassName) {
|
|
|
|
{
|
|
|
|
|
|
|
|
if (class_exists($sClassName)) {
|
|
|
|
if (class_exists($sClassName)) {
|
|
|
|
$this->_itemClass = $sClassName;
|
|
|
|
$this->_itemClass = $sClassName;
|
|
|
|
$this->_itemClassInstance = new $sClassName;
|
|
|
|
$this->_itemClassInstance = new $sClassName;
|
|
|
@ -229,8 +207,7 @@ abstract class ItemCollection extends cItemBaseAbstract
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @param $bForceInit boolean If true, forces the driver to initialize, even if it already exists.
|
|
|
|
* @param $bForceInit boolean If true, forces the driver to initialize, even if it already exists.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
protected function _initializeDriver($bForceInit = false)
|
|
|
|
protected function _initializeDriver($bForceInit = false) {
|
|
|
|
{
|
|
|
|
|
|
|
|
if (!is_object($this->_driver) || $bForceInit == true) {
|
|
|
|
if (!is_object($this->_driver) || $bForceInit == true) {
|
|
|
|
$this->_driver = new gdbMySQL();
|
|
|
|
$this->_driver = new gdbMySQL();
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -240,8 +217,7 @@ abstract class ItemCollection extends cItemBaseAbstract
|
|
|
|
* Sets the encoding.
|
|
|
|
* Sets the encoding.
|
|
|
|
* @param string $sEncoding
|
|
|
|
* @param string $sEncoding
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public function setEncoding($sEncoding)
|
|
|
|
public function setEncoding($sEncoding) {
|
|
|
|
{
|
|
|
|
|
|
|
|
$this->_encoding = $sEncoding;
|
|
|
|
$this->_encoding = $sEncoding;
|
|
|
|
$this->_driver->setEncoding($sEncoding);
|
|
|
|
$this->_driver->setEncoding($sEncoding);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -250,8 +226,7 @@ abstract class ItemCollection extends cItemBaseAbstract
|
|
|
|
* Sets the query to use foreign tables in the resultset
|
|
|
|
* Sets the query to use foreign tables in the resultset
|
|
|
|
* @param string $sForeignClass The class of foreign table to use
|
|
|
|
* @param string $sForeignClass The class of foreign table to use
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public function link($sForeignClass)
|
|
|
|
public function link($sForeignClass) {
|
|
|
|
{
|
|
|
|
|
|
|
|
if (class_exists($sForeignClass)) {
|
|
|
|
if (class_exists($sForeignClass)) {
|
|
|
|
$this->_links[$sForeignClass] = new $sForeignClass;
|
|
|
|
$this->_links[$sForeignClass] = new $sForeignClass;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
@ -266,8 +241,7 @@ abstract class ItemCollection extends cItemBaseAbstract
|
|
|
|
* @param int $iRowStart
|
|
|
|
* @param int $iRowStart
|
|
|
|
* @param int $iRowCount
|
|
|
|
* @param int $iRowCount
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public function setLimit($iRowStart, $iRowCount)
|
|
|
|
public function setLimit($iRowStart, $iRowCount) {
|
|
|
|
{
|
|
|
|
|
|
|
|
$this->_limitStart = $iRowStart;
|
|
|
|
$this->_limitStart = $iRowStart;
|
|
|
|
$this->_limitCount = $iRowCount;
|
|
|
|
$this->_limitCount = $iRowCount;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -278,8 +252,7 @@ abstract class ItemCollection extends cItemBaseAbstract
|
|
|
|
* @param mixed $mRestriction
|
|
|
|
* @param mixed $mRestriction
|
|
|
|
* @param string $sOperator
|
|
|
|
* @param string $sOperator
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public function setWhere($sField, $mRestriction, $sOperator = '=')
|
|
|
|
public function setWhere($sField, $mRestriction, $sOperator = '=') {
|
|
|
|
{
|
|
|
|
|
|
|
|
$sField = strtolower($sField);
|
|
|
|
$sField = strtolower($sField);
|
|
|
|
$this->_where['global'][$sField]['operator'] = $sOperator;
|
|
|
|
$this->_where['global'][$sField]['operator'] = $sOperator;
|
|
|
|
$this->_where['global'][$sField]['restriction'] = $mRestriction;
|
|
|
|
$this->_where['global'][$sField]['restriction'] = $mRestriction;
|
|
|
@ -291,12 +264,10 @@ abstract class ItemCollection extends cItemBaseAbstract
|
|
|
|
* @param mixed $mRestriction
|
|
|
|
* @param mixed $mRestriction
|
|
|
|
* @param string $sOperator
|
|
|
|
* @param string $sOperator
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public function deleteWhere($sField, $mRestriction, $sOperator = '=')
|
|
|
|
public function deleteWhere($sField, $mRestriction, $sOperator = '=') {
|
|
|
|
{
|
|
|
|
|
|
|
|
$sField = strtolower($sField);
|
|
|
|
$sField = strtolower($sField);
|
|
|
|
if (isset($this->_where['global'][$sField]) && is_array($this->_where['global'][$sField])) {
|
|
|
|
if (isset($this->_where['global'][$sField]) && is_array($this->_where['global'][$sField])) {
|
|
|
|
if ($this->_where['global'][$sField]['operator'] == $sOperator &&
|
|
|
|
if ($this->_where['global'][$sField]['operator'] == $sOperator && $this->_where['global'][$sField]['restriction'] == $mRestriction) {
|
|
|
|
$this->_where['global'][$sField]['restriction'] == $mRestriction) {
|
|
|
|
|
|
|
|
unset($this->_where['global'][$sField]);
|
|
|
|
unset($this->_where['global'][$sField]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -309,8 +280,7 @@ abstract class ItemCollection extends cItemBaseAbstract
|
|
|
|
* @param mixed $mRestriction
|
|
|
|
* @param mixed $mRestriction
|
|
|
|
* @param string $sOperator
|
|
|
|
* @param string $sOperator
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public function setWhereGroup($sGroup, $sField, $mRestriction, $sOperator = '=')
|
|
|
|
public function setWhereGroup($sGroup, $sField, $mRestriction, $sOperator = '=') {
|
|
|
|
{
|
|
|
|
|
|
|
|
$sField = strtolower($sField);
|
|
|
|
$sField = strtolower($sField);
|
|
|
|
$this->_where['groups'][$sGroup][$sField]['operator'] = $sOperator;
|
|
|
|
$this->_where['groups'][$sGroup][$sField]['operator'] = $sOperator;
|
|
|
|
$this->_where['groups'][$sGroup][$sField]['restriction'] = $mRestriction;
|
|
|
|
$this->_where['groups'][$sGroup][$sField]['restriction'] = $mRestriction;
|
|
|
@ -323,14 +293,10 @@ abstract class ItemCollection extends cItemBaseAbstract
|
|
|
|
* @param mixed $mRestriction
|
|
|
|
* @param mixed $mRestriction
|
|
|
|
* @param string $sOperator
|
|
|
|
* @param string $sOperator
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public function deleteWhereGroup($sGroup, $sField, $mRestriction, $sOperator = '=')
|
|
|
|
public function deleteWhereGroup($sGroup, $sField, $mRestriction, $sOperator = '=') {
|
|
|
|
{
|
|
|
|
|
|
|
|
$sField = strtolower($sField);
|
|
|
|
$sField = strtolower($sField);
|
|
|
|
if (is_array($this->_where['groups'][$sGroup]) &&
|
|
|
|
if (is_array($this->_where['groups'][$sGroup]) && isset($this->_where['groups'][$sGroup][$sField]) && is_array($this->_where['groups'][$sGroup][$sField])) {
|
|
|
|
isset($this->_where['groups'][$sGroup][$sField]) &&
|
|
|
|
if ($this->_where['groups'][$sGroup][$sField]['operator'] == $sOperator && $this->_where['groups'][$sGroup][$sField]['restriction'] == $mRestriction) {
|
|
|
|
is_array($this->_where['groups'][$sGroup][$sField])) {
|
|
|
|
|
|
|
|
if ($this->_where['groups'][$sGroup][$sField]['operator'] == $sOperator &&
|
|
|
|
|
|
|
|
$this->_where['groups'][$sGroup][$sField]['restriction'] == $mRestriction) {
|
|
|
|
|
|
|
|
unset($this->_where['groups'][$sGroup][$sField]);
|
|
|
|
unset($this->_where['groups'][$sGroup][$sField]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -341,8 +307,7 @@ abstract class ItemCollection extends cItemBaseAbstract
|
|
|
|
* @param string $sGroup
|
|
|
|
* @param string $sGroup
|
|
|
|
* @param string $sCondition
|
|
|
|
* @param string $sCondition
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public function setInnerGroupCondition($sGroup, $sCondition = 'AND')
|
|
|
|
public function setInnerGroupCondition($sGroup, $sCondition = 'AND') {
|
|
|
|
{
|
|
|
|
|
|
|
|
$this->_innerGroupConditions[$sGroup] = $sCondition;
|
|
|
|
$this->_innerGroupConditions[$sGroup] = $sCondition;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -352,8 +317,7 @@ abstract class ItemCollection extends cItemBaseAbstract
|
|
|
|
* @param string $sGroup2
|
|
|
|
* @param string $sGroup2
|
|
|
|
* @param string $sCondition
|
|
|
|
* @param string $sCondition
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public function setGroupCondition($sGroup1, $sGroup2, $sCondition = 'AND')
|
|
|
|
public function setGroupCondition($sGroup1, $sGroup2, $sCondition = 'AND') {
|
|
|
|
{
|
|
|
|
|
|
|
|
$this->_groupConditions[$sGroup1][$sGroup2] = $sCondition;
|
|
|
|
$this->_groupConditions[$sGroup1][$sGroup2] = $sCondition;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -362,8 +326,7 @@ abstract class ItemCollection extends cItemBaseAbstract
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @return array With all where statements
|
|
|
|
* @return array With all where statements
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
protected function _buildGroupWhereStatements()
|
|
|
|
protected function _buildGroupWhereStatements() {
|
|
|
|
{
|
|
|
|
|
|
|
|
$aWheres = array();
|
|
|
|
$aWheres = array();
|
|
|
|
$aGroupWhere = array();
|
|
|
|
$aGroupWhere = array();
|
|
|
|
|
|
|
|
|
|
|
@ -388,7 +351,7 @@ abstract class ItemCollection extends cItemBaseAbstract
|
|
|
|
$sOperator = $this->_innerGroupConditions[$groupname];
|
|
|
|
$sOperator = $this->_innerGroupConditions[$groupname];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$aGroupWhere[$groupname] = implode(' '.$sOperator.' ', $aWheres);
|
|
|
|
$aGroupWhere[$groupname] = implode(' ' . $sOperator . ' ', $aWheres);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -410,9 +373,9 @@ abstract class ItemCollection extends cItemBaseAbstract
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$sGroupWhereStatement .= ' '.$sOperator.' ('.$group.')';
|
|
|
|
$sGroupWhereStatement .= ' ' . $sOperator . ' (' . $group . ')';
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
$sGroupWhereStatement .= '('.$group.')';
|
|
|
|
$sGroupWhereStatement .= '(' . $group . ')';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$mLastGroup = $groupname;
|
|
|
|
$mLastGroup = $groupname;
|
|
|
@ -426,8 +389,7 @@ abstract class ItemCollection extends cItemBaseAbstract
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @return array With all where statements
|
|
|
|
* @return array With all where statements
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
protected function _buildWhereStatements()
|
|
|
|
protected function _buildWhereStatements() {
|
|
|
|
{
|
|
|
|
|
|
|
|
$aWheres = array();
|
|
|
|
$aWheres = array();
|
|
|
|
|
|
|
|
|
|
|
|
// Build global where condition
|
|
|
|
// Build global where condition
|
|
|
@ -462,8 +424,7 @@ abstract class ItemCollection extends cItemBaseAbstract
|
|
|
|
* @param ??? $ignoreRoot
|
|
|
|
* @param ??? $ignoreRoot
|
|
|
|
* @return array Array structure, see above
|
|
|
|
* @return array Array structure, see above
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
protected function _fetchJoinTables($ignoreRoot)
|
|
|
|
protected function _fetchJoinTables($ignoreRoot) {
|
|
|
|
{
|
|
|
|
|
|
|
|
$aParameters = array();
|
|
|
|
$aParameters = array();
|
|
|
|
$aFields = array();
|
|
|
|
$aFields = array();
|
|
|
|
$aTables = array();
|
|
|
|
$aTables = array();
|
|
|
@ -511,7 +472,7 @@ abstract class ItemCollection extends cItemBaseAbstract
|
|
|
|
$matches['key']
|
|
|
|
$matches['key']
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
if ($i['field'] == ($link.'.'.$mobject->primaryKey) && $link == $ignoreRoot) {
|
|
|
|
if ($i['field'] == ($link . '.' . $mobject->primaryKey) && $link == $ignoreRoot) {
|
|
|
|
unset($i['join']);
|
|
|
|
unset($i['join']);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$aParameters[] = $i;
|
|
|
|
$aParameters[] = $i;
|
|
|
@ -527,8 +488,7 @@ abstract class ItemCollection extends cItemBaseAbstract
|
|
|
|
$match['key']
|
|
|
|
$match['key']
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
if ($i['field'] == ($match['sourceclass'] . '.' . $xobject->primaryKey) &&
|
|
|
|
if ($i['field'] == ($match['sourceclass'] . '.' . $xobject->primaryKey) && $match['sourceclass'] == $ignoreRoot) {
|
|
|
|
$match['sourceclass'] == $ignoreRoot) {
|
|
|
|
|
|
|
|
unset($i['join']);
|
|
|
|
unset($i['join']);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
array_unshift($aParameters, $i);
|
|
|
|
array_unshift($aParameters, $i);
|
|
|
@ -555,8 +515,7 @@ abstract class ItemCollection extends cItemBaseAbstract
|
|
|
|
$matches['key']
|
|
|
|
$matches['key']
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
if ($i['field'] == ($link . '.' . $mobject->primaryKey) &&
|
|
|
|
if ($i['field'] == ($link . '.' . $mobject->primaryKey) && $link == $ignoreRoot) {
|
|
|
|
$link == $ignoreRoot) {
|
|
|
|
|
|
|
|
unset($i['join']);
|
|
|
|
unset($i['join']);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$aParameters[] = $i;
|
|
|
|
$aParameters[] = $i;
|
|
|
@ -572,8 +531,7 @@ abstract class ItemCollection extends cItemBaseAbstract
|
|
|
|
$match['key']
|
|
|
|
$match['key']
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
if ($i['field'] == ($match['sourceclass'] . '.' . $xobject->primaryKey) &&
|
|
|
|
if ($i['field'] == ($match['sourceclass'] . '.' . $xobject->primaryKey) && $match['sourceclass'] == $ignoreRoot) {
|
|
|
|
$match['sourceclass'] == $ignoreRoot) {
|
|
|
|
|
|
|
|
unset($i['join']);
|
|
|
|
unset($i['join']);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
array_unshift($aParameters, $i);
|
|
|
|
array_unshift($aParameters, $i);
|
|
|
@ -609,7 +567,7 @@ abstract class ItemCollection extends cItemBaseAbstract
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
$sMsg = "Could not find join partner for class [$link] in class "
|
|
|
|
$sMsg = "Could not find join partner for class [$link] in class "
|
|
|
|
. get_class($this)." in neither forward nor reverse direction.";
|
|
|
|
. get_class($this) . " in neither forward nor reverse direction.";
|
|
|
|
cWarning(__FILE__, __LINE__, $sMsg);
|
|
|
|
cWarning(__FILE__, __LINE__, $sMsg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -618,7 +576,7 @@ abstract class ItemCollection extends cItemBaseAbstract
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Add this class
|
|
|
|
// Add this class
|
|
|
|
$aFields[] = strtolower(strtolower(get_class($this))).'.'.$this->primaryKey;
|
|
|
|
$aFields[] = strtolower(strtolower(get_class($this))) . '.' . $this->primaryKey;
|
|
|
|
|
|
|
|
|
|
|
|
// Make the parameters unique
|
|
|
|
// Make the parameters unique
|
|
|
|
foreach ($aParameters as $parameter) {
|
|
|
|
foreach ($aParameters as $parameter) {
|
|
|
@ -643,8 +601,7 @@ abstract class ItemCollection extends cItemBaseAbstract
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @return array
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
protected function _resolveLinks()
|
|
|
|
protected function _resolveLinks() {
|
|
|
|
{
|
|
|
|
|
|
|
|
$aResolvedLinks = array();
|
|
|
|
$aResolvedLinks = array();
|
|
|
|
$aResolvedLinks[] = strtolower(get_class($this));
|
|
|
|
$aResolvedLinks[] = strtolower(get_class($this));
|
|
|
|
|
|
|
|
|
|
|
@ -658,8 +615,7 @@ abstract class ItemCollection extends cItemBaseAbstract
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Resets the properties
|
|
|
|
* Resets the properties
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public function resetQuery()
|
|
|
|
public function resetQuery() {
|
|
|
|
{
|
|
|
|
|
|
|
|
$this->setLimit(0, 0);
|
|
|
|
$this->setLimit(0, 0);
|
|
|
|
$this->_JoinPartners = array();
|
|
|
|
$this->_JoinPartners = array();
|
|
|
|
$this->_forwardJoinPartners = array();
|
|
|
|
$this->_forwardJoinPartners = array();
|
|
|
@ -675,8 +631,7 @@ abstract class ItemCollection extends cItemBaseAbstract
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @return bool
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public function query()
|
|
|
|
public function query() {
|
|
|
|
{
|
|
|
|
|
|
|
|
if (!isset($this->_itemClassInstance)) {
|
|
|
|
if (!isset($this->_itemClassInstance)) {
|
|
|
|
$sMsg = "GenericDB can't use query() if no item class is set via setItemClass";
|
|
|
|
$sMsg = "GenericDB can't use query() if no item class is set via setItemClass";
|
|
|
|
cWarning(__FILE__, __LINE__, $sMsg);
|
|
|
|
cWarning(__FILE__, __LINE__, $sMsg);
|
|
|
@ -717,11 +672,11 @@ abstract class ItemCollection extends cItemBaseAbstract
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (count($aWheres) > 0) {
|
|
|
|
if (count($aWheres) > 0) {
|
|
|
|
$aStatement[] = 'WHERE '.implode(' AND ', $aWheres);
|
|
|
|
$aStatement[] = 'WHERE ' . implode(' AND ', $aWheres);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ($this->_order != '') {
|
|
|
|
if ($this->_order != '') {
|
|
|
|
$aStatement[] = 'ORDER BY '.$this->_order;
|
|
|
|
$aStatement[] = 'ORDER BY ' . $this->_order;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ($this->_limitStart > 0 || $this->_limitCount > 0) {
|
|
|
|
if ($this->_limitStart > 0 || $this->_limitCount > 0) {
|
|
|
@ -745,8 +700,7 @@ abstract class ItemCollection extends cItemBaseAbstract
|
|
|
|
* (e. g. "fieldname", "fieldname DESC", "fieldname DESC, field2name ASC")
|
|
|
|
* (e. g. "fieldname", "fieldname DESC", "fieldname DESC, field2name ASC")
|
|
|
|
* @param string $order
|
|
|
|
* @param string $order
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public function setOrder($order)
|
|
|
|
public function setOrder($order) {
|
|
|
|
{
|
|
|
|
|
|
|
|
$this->_order = strtolower($order);
|
|
|
|
$this->_order = strtolower($order);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -754,8 +708,7 @@ abstract class ItemCollection extends cItemBaseAbstract
|
|
|
|
* Adds a result field
|
|
|
|
* Adds a result field
|
|
|
|
* @param string $sField
|
|
|
|
* @param string $sField
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public function addResultField($sField)
|
|
|
|
public function addResultField($sField) {
|
|
|
|
{
|
|
|
|
|
|
|
|
$sField = strtolower($sField);
|
|
|
|
$sField = strtolower($sField);
|
|
|
|
if (!in_array($sField, $this->_resultFields)) {
|
|
|
|
if (!in_array($sField, $this->_resultFields)) {
|
|
|
|
$this->_resultFields[] = $sField;
|
|
|
|
$this->_resultFields[] = $sField;
|
|
|
@ -766,8 +719,7 @@ abstract class ItemCollection extends cItemBaseAbstract
|
|
|
|
* Removes existing result field
|
|
|
|
* Removes existing result field
|
|
|
|
* @param string $sField
|
|
|
|
* @param string $sField
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public function removeResultField($sField)
|
|
|
|
public function removeResultField($sField) {
|
|
|
|
{
|
|
|
|
|
|
|
|
$sField = strtolower($sField);
|
|
|
|
$sField = strtolower($sField);
|
|
|
|
$key = array_search($sField, $this->_resultFields);
|
|
|
|
$key = array_search($sField, $this->_resultFields);
|
|
|
|
if ($key !== false) {
|
|
|
|
if ($key !== false) {
|
|
|
@ -782,8 +734,7 @@ abstract class ItemCollection extends cItemBaseAbstract
|
|
|
|
* @param string $sClassName
|
|
|
|
* @param string $sClassName
|
|
|
|
* @param array|bool
|
|
|
|
* @param array|bool
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
protected function _findReverseJoinPartner($sParentClass, $sClassName)
|
|
|
|
protected function _findReverseJoinPartner($sParentClass, $sClassName) {
|
|
|
|
{
|
|
|
|
|
|
|
|
// Make the parameters lowercase, as get_class is buggy
|
|
|
|
// Make the parameters lowercase, as get_class is buggy
|
|
|
|
$sClassName = strtolower($sClassName);
|
|
|
|
$sClassName = strtolower($sClassName);
|
|
|
|
$sParentClass = strtolower($sParentClass);
|
|
|
|
$sParentClass = strtolower($sParentClass);
|
|
|
@ -835,26 +786,25 @@ abstract class ItemCollection extends cItemBaseAbstract
|
|
|
|
* @param string $sLimit Specifies the limit by clause.
|
|
|
|
* @param string $sLimit Specifies the limit by clause.
|
|
|
|
* @return bool True on success, otherwhise false
|
|
|
|
* @return bool True on success, otherwhise false
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public function select($sWhere = '', $sGroupBy = '', $sOrderBy = '', $sLimit = '')
|
|
|
|
public function select($sWhere = '', $sGroupBy = '', $sOrderBy = '', $sLimit = '') {
|
|
|
|
{
|
|
|
|
|
|
|
|
unset($this->objects);
|
|
|
|
unset($this->objects);
|
|
|
|
|
|
|
|
|
|
|
|
if ($sWhere == '') {
|
|
|
|
if ($sWhere == '') {
|
|
|
|
$sWhere = '';
|
|
|
|
$sWhere = '';
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
$sWhere = ' WHERE '.$sWhere;
|
|
|
|
$sWhere = ' WHERE ' . $sWhere;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ($sGroupBy != '') {
|
|
|
|
if ($sGroupBy != '') {
|
|
|
|
$sGroupBy = ' GROUP BY '.$sGroupBy;
|
|
|
|
$sGroupBy = ' GROUP BY ' . $sGroupBy;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ($sOrderBy != '') {
|
|
|
|
if ($sOrderBy != '') {
|
|
|
|
$sOrderBy = ' ORDER BY '.$sOrderBy;
|
|
|
|
$sOrderBy = ' ORDER BY ' . $sOrderBy;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ($sLimit != '') {
|
|
|
|
if ($sLimit != '') {
|
|
|
|
$sLimit = ' LIMIT '.$sLimit;
|
|
|
|
$sLimit = ' LIMIT ' . $sLimit;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$sFields = ($this->_settings['select_all_mode']) ? '*' : $this->primaryKey;
|
|
|
|
$sFields = ($this->_settings['select_all_mode']) ? '*' : $this->primaryKey;
|
|
|
@ -885,8 +835,7 @@ abstract class ItemCollection extends cItemBaseAbstract
|
|
|
|
* @return bool True on success, otherwhise false
|
|
|
|
* @return bool True on success, otherwhise false
|
|
|
|
* @author HerrB
|
|
|
|
* @author HerrB
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public function flexSelect($sDistinct = '', $sFrom = '', $sWhere = '', $sGroupBy = '', $sOrderBy = '', $sLimit = '')
|
|
|
|
public function flexSelect($sDistinct = '', $sFrom = '', $sWhere = '', $sGroupBy = '', $sOrderBy = '', $sLimit = '') {
|
|
|
|
{
|
|
|
|
|
|
|
|
unset($this->objects);
|
|
|
|
unset($this->objects);
|
|
|
|
|
|
|
|
|
|
|
|
if ($sDistinct != '') {
|
|
|
|
if ($sDistinct != '') {
|
|
|
@ -894,23 +843,23 @@ abstract class ItemCollection extends cItemBaseAbstract
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ($sFrom != '') {
|
|
|
|
if ($sFrom != '') {
|
|
|
|
$sFrom = ', '.$sFrom;
|
|
|
|
$sFrom = ', ' . $sFrom;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ($sWhere != '') {
|
|
|
|
if ($sWhere != '') {
|
|
|
|
$sWhere = ' WHERE '.$sWhere;
|
|
|
|
$sWhere = ' WHERE ' . $sWhere;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ($sGroupBy != '') {
|
|
|
|
if ($sGroupBy != '') {
|
|
|
|
$sGroupBy = ' GROUP BY '.$sGroupBy;
|
|
|
|
$sGroupBy = ' GROUP BY ' . $sGroupBy;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ($sOrderBy != '') {
|
|
|
|
if ($sOrderBy != '') {
|
|
|
|
$sOrderBy = ' ORDER BY '.$sOrderBy;
|
|
|
|
$sOrderBy = ' ORDER BY ' . $sOrderBy;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ($sLimit != '') {
|
|
|
|
if ($sLimit != '') {
|
|
|
|
$sLimit = ' LIMIT '.$sLimit;
|
|
|
|
$sLimit = ' LIMIT ' . $sLimit;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$sql = 'SELECT ' . $sDistinct . strtolower(get_class($this)) . '.' . $this->primaryKey
|
|
|
|
$sql = 'SELECT ' . $sDistinct . strtolower(get_class($this)) . '.' . $this->primaryKey
|
|
|
@ -935,8 +884,7 @@ abstract class ItemCollection extends cItemBaseAbstract
|
|
|
|
* @param mixed $mId The id to check for (could be numeric or string)
|
|
|
|
* @param mixed $mId The id to check for (could be numeric or string)
|
|
|
|
* @return bool True if object exists, false if not
|
|
|
|
* @return bool True if object exists, false if not
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public function exists($mId)
|
|
|
|
public function exists($mId) {
|
|
|
|
{
|
|
|
|
|
|
|
|
$oDb = $this->_getSecondDBInstance();
|
|
|
|
$oDb = $this->_getSecondDBInstance();
|
|
|
|
$sql = "SELECT `%s` FROM %s WHERE %s='%s'";
|
|
|
|
$sql = "SELECT `%s` FROM %s WHERE %s='%s'";
|
|
|
|
$oDb->query($sql, $this->primaryKey, $this->table, $this->primaryKey, $mId);
|
|
|
|
$oDb->query($sql, $this->primaryKey, $this->table, $this->primaryKey, $mId);
|
|
|
@ -948,8 +896,7 @@ abstract class ItemCollection extends cItemBaseAbstract
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @return Item|bool The next object, or false if no more objects
|
|
|
|
* @return Item|bool The next object, or false if no more objects
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public function next()
|
|
|
|
public function next() {
|
|
|
|
{
|
|
|
|
|
|
|
|
if ($this->db->next_record()) {
|
|
|
|
if ($this->db->next_record()) {
|
|
|
|
if ($this->_bAllMode) {
|
|
|
|
if ($this->_bAllMode) {
|
|
|
|
$aRs = $this->db->toArray(DB_ConLite::FETCH_BOTH);
|
|
|
|
$aRs = $this->db->toArray(DB_ConLite::FETCH_BOTH);
|
|
|
@ -967,8 +914,7 @@ abstract class ItemCollection extends cItemBaseAbstract
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @param Item
|
|
|
|
* @param Item
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public function fetchObject($sClassName)
|
|
|
|
public function fetchObject($sClassName) {
|
|
|
|
{
|
|
|
|
|
|
|
|
$sKey = strtolower($sClassName);
|
|
|
|
$sKey = strtolower($sClassName);
|
|
|
|
|
|
|
|
|
|
|
|
if (!is_object($this->_collectionCache[$sKey])) {
|
|
|
|
if (!is_object($this->_collectionCache[$sKey])) {
|
|
|
@ -997,7 +943,7 @@ abstract class ItemCollection extends cItemBaseAbstract
|
|
|
|
$row = 1;
|
|
|
|
$row = 1;
|
|
|
|
$aTable = array();
|
|
|
|
$aTable = array();
|
|
|
|
|
|
|
|
|
|
|
|
if(empty($aFields) && empty($aObjects)) {
|
|
|
|
if (empty($aFields) && empty($aObjects)) {
|
|
|
|
$aFields = array($this->primaryKey);
|
|
|
|
$aFields = array($this->primaryKey);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -1014,7 +960,7 @@ abstract class ItemCollection extends cItemBaseAbstract
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Fetch objects
|
|
|
|
// Fetch objects
|
|
|
|
if(!empty($aObjects)) {
|
|
|
|
if (!empty($aObjects)) {
|
|
|
|
foreach ($aObjects as $alias => $object) {
|
|
|
|
foreach ($aObjects as $alias => $object) {
|
|
|
|
if ($alias != '') {
|
|
|
|
if ($alias != '') {
|
|
|
|
if (isset($aTable[$row][$alias])) {
|
|
|
|
if (isset($aTable[$row][$alias])) {
|
|
|
@ -1034,7 +980,7 @@ abstract class ItemCollection extends cItemBaseAbstract
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$row ++;
|
|
|
|
$row++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$this->db->seek(0);
|
|
|
|
$this->db->seek(0);
|
|
|
@ -1047,8 +993,7 @@ abstract class ItemCollection extends cItemBaseAbstract
|
|
|
|
* @param array $aObjects With the correct order of the objects
|
|
|
|
* @param array $aObjects With the correct order of the objects
|
|
|
|
* @return array Result
|
|
|
|
* @return array Result
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public function queryAndFetchStructured(array $aObjects)
|
|
|
|
public function queryAndFetchStructured(array $aObjects) {
|
|
|
|
{
|
|
|
|
|
|
|
|
$aOrder = array();
|
|
|
|
$aOrder = array();
|
|
|
|
$aFetchObjects = array();
|
|
|
|
$aFetchObjects = array();
|
|
|
|
$aResult = array();
|
|
|
|
$aResult = array();
|
|
|
@ -1056,7 +1001,7 @@ abstract class ItemCollection extends cItemBaseAbstract
|
|
|
|
foreach ($aObjects as $object) {
|
|
|
|
foreach ($aObjects as $object) {
|
|
|
|
$x = new $object;
|
|
|
|
$x = new $object;
|
|
|
|
$object = strtolower($object);
|
|
|
|
$object = strtolower($object);
|
|
|
|
$aOrder[] = $object.'.'.$x->primaryKey.' ASC';
|
|
|
|
$aOrder[] = $object . '.' . $x->primaryKey . ' ASC';
|
|
|
|
$aFetchObjects[] = $x;
|
|
|
|
$aFetchObjects[] = $x;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -1072,8 +1017,7 @@ abstract class ItemCollection extends cItemBaseAbstract
|
|
|
|
return $aResult;
|
|
|
|
return $aResult;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected function _recursiveStructuredFetch(array $aObjects, array $aResult)
|
|
|
|
protected function _recursiveStructuredFetch(array $aObjects, array $aResult) {
|
|
|
|
{
|
|
|
|
|
|
|
|
$i = array_shift($aObjects);
|
|
|
|
$i = array_shift($aObjects);
|
|
|
|
|
|
|
|
|
|
|
|
$value = $this->db->f($i->primaryKey);
|
|
|
|
$value = $this->db->f($i->primaryKey);
|
|
|
@ -1094,8 +1038,7 @@ abstract class ItemCollection extends cItemBaseAbstract
|
|
|
|
* Returns the amount of returned items
|
|
|
|
* Returns the amount of returned items
|
|
|
|
* @return int Number of rows
|
|
|
|
* @return int Number of rows
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public function count()
|
|
|
|
public function count() {
|
|
|
|
{
|
|
|
|
|
|
|
|
return ($this->db->num_rows());
|
|
|
|
return ($this->db->num_rows());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -1105,8 +1048,7 @@ abstract class ItemCollection extends cItemBaseAbstract
|
|
|
|
* @param string|int $id The primary key of the item to load.
|
|
|
|
* @param string|int $id The primary key of the item to load.
|
|
|
|
* @return Item The loaded item
|
|
|
|
* @return Item The loaded item
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public function fetchById($id)
|
|
|
|
public function fetchById($id) {
|
|
|
|
{
|
|
|
|
|
|
|
|
if (is_numeric($id)) {
|
|
|
|
if (is_numeric($id)) {
|
|
|
|
$id = (int) $id;
|
|
|
|
$id = (int) $id;
|
|
|
|
} elseif (is_string($id)) {
|
|
|
|
} elseif (is_string($id)) {
|
|
|
@ -1123,8 +1065,7 @@ abstract class ItemCollection extends cItemBaseAbstract
|
|
|
|
* @return Item The newly created object
|
|
|
|
* @return Item The newly created object
|
|
|
|
* @throws Contenido_ItemException If item class is not set
|
|
|
|
* @throws Contenido_ItemException If item class is not set
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public function loadItem($mItem)
|
|
|
|
public function loadItem($mItem) {
|
|
|
|
{
|
|
|
|
|
|
|
|
if (empty($this->_itemClass)) {
|
|
|
|
if (empty($this->_itemClass)) {
|
|
|
|
$sMsg = "ItemClass has to be set in the constructor of class "
|
|
|
|
$sMsg = "ItemClass has to be set in the constructor of class "
|
|
|
|
. get_class($this) . ")";
|
|
|
|
. get_class($this) . ")";
|
|
|
@ -1150,12 +1091,11 @@ abstract class ItemCollection extends cItemBaseAbstract
|
|
|
|
* @param string $primaryKeyValue Optional parameter for direct input of primary key value
|
|
|
|
* @param string $primaryKeyValue Optional parameter for direct input of primary key value
|
|
|
|
* @return Item The newly created object
|
|
|
|
* @return Item The newly created object
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public function createNewItem($aData = NULL)
|
|
|
|
public function createNewItem($aData = NULL) { /* @var $oDb DB_ConLite */
|
|
|
|
{ /* @var $oDb DB_ConLite */
|
|
|
|
|
|
|
|
$oDb = $this->_getSecondDBInstance();
|
|
|
|
$oDb = $this->_getSecondDBInstance();
|
|
|
|
if(is_null($aData) || empty($aData)) {
|
|
|
|
if (is_null($aData) || empty($aData)) {
|
|
|
|
$iNextId = $oDb->nextid($this->table);
|
|
|
|
$iNextId = $oDb->nextid($this->table);
|
|
|
|
} else if(is_array($aData) && key_exists($this->primaryKey, $aData)) {
|
|
|
|
} else if (is_array($aData) && key_exists($this->primaryKey, $aData)) {
|
|
|
|
$iNextId = (int) $aData[$this->primaryKey];
|
|
|
|
$iNextId = (int) $aData[$this->primaryKey];
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
$iNextId = (int) $aData;
|
|
|
|
$iNextId = (int) $aData;
|
|
|
@ -1173,8 +1113,7 @@ abstract class ItemCollection extends cItemBaseAbstract
|
|
|
|
* @param mixed $mId Id of entry to delete
|
|
|
|
* @param mixed $mId Id of entry to delete
|
|
|
|
* @return bool
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public function delete($mId)
|
|
|
|
public function delete($mId) {
|
|
|
|
{
|
|
|
|
|
|
|
|
$result = $this->_delete($mId);
|
|
|
|
$result = $this->_delete($mId);
|
|
|
|
|
|
|
|
|
|
|
|
return $result;
|
|
|
|
return $result;
|
|
|
@ -1187,8 +1126,7 @@ abstract class ItemCollection extends cItemBaseAbstract
|
|
|
|
* @param string $sWhere The where clause of the SQL statement
|
|
|
|
* @param string $sWhere The where clause of the SQL statement
|
|
|
|
* @return int Number of deleted entries
|
|
|
|
* @return int Number of deleted entries
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public function deleteByWhereClause($sWhere)
|
|
|
|
public function deleteByWhereClause($sWhere) {
|
|
|
|
{
|
|
|
|
|
|
|
|
$oDb = $this->_getSecondDBInstance();
|
|
|
|
$oDb = $this->_getSecondDBInstance();
|
|
|
|
|
|
|
|
|
|
|
|
$aIds = array();
|
|
|
|
$aIds = array();
|
|
|
@ -1219,8 +1157,7 @@ abstract class ItemCollection extends cItemBaseAbstract
|
|
|
|
* @param mixed $mValue The value of the field
|
|
|
|
* @param mixed $mValue The value of the field
|
|
|
|
* @return int Number of deleted entries
|
|
|
|
* @return int Number of deleted entries
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public function deleteBy($sField, $mValue)
|
|
|
|
public function deleteBy($sField, $mValue) {
|
|
|
|
{
|
|
|
|
|
|
|
|
$oDb = $this->_getSecondDBInstance();
|
|
|
|
$oDb = $this->_getSecondDBInstance();
|
|
|
|
|
|
|
|
|
|
|
|
$aIds = array();
|
|
|
|
$aIds = array();
|
|
|
@ -1270,7 +1207,7 @@ abstract class ItemCollection extends cItemBaseAbstract
|
|
|
|
$sql = "DELETE FROM `%s` WHERE %s = '%s'";
|
|
|
|
$sql = "DELETE FROM `%s` WHERE %s = '%s'";
|
|
|
|
$oDb->query($sql, $this->table, $this->primaryKey, $mId);
|
|
|
|
$oDb->query($sql, $this->table, $this->primaryKey, $mId);
|
|
|
|
|
|
|
|
|
|
|
|
return (($oDb->affected_rows() > 0)?true:false);
|
|
|
|
return (($oDb->affected_rows() > 0) ? true : false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -1288,8 +1225,7 @@ abstract class ItemCollection extends cItemBaseAbstract
|
|
|
|
* @param mixed $mFields String or array
|
|
|
|
* @param mixed $mFields String or array
|
|
|
|
* @return array Resulting array
|
|
|
|
* @return array Resulting array
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public function fetchArray($sKey, $mFields)
|
|
|
|
public function fetchArray($sKey, $mFields) {
|
|
|
|
{
|
|
|
|
|
|
|
|
$aResult = array();
|
|
|
|
$aResult = array();
|
|
|
|
|
|
|
|
|
|
|
|
while ($item = $this->next()) {
|
|
|
|
while ($item = $this->next()) {
|
|
|
@ -1316,8 +1252,8 @@ abstract class ItemCollection extends cItemBaseAbstract
|
|
|
|
* @version 0.3
|
|
|
|
* @version 0.3
|
|
|
|
* @copyright four for business 2003
|
|
|
|
* @copyright four for business 2003
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
abstract class Item extends cItemBaseAbstract
|
|
|
|
abstract class Item extends cItemBaseAbstract {
|
|
|
|
{
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Storage of the source table to use for the user informations
|
|
|
|
* Storage of the source table to use for the user informations
|
|
|
|
* @var array
|
|
|
|
* @var array
|
|
|
@ -1362,8 +1298,7 @@ abstract class Item extends cItemBaseAbstract
|
|
|
|
* @param string $sPrimaryKey The primary key to use
|
|
|
|
* @param string $sPrimaryKey The primary key to use
|
|
|
|
* @param int $iLifetime
|
|
|
|
* @param int $iLifetime
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public function __construct($sTable = '', $sPrimaryKey = '', $iLifetime = 10)
|
|
|
|
public function __construct($sTable = '', $sPrimaryKey = '', $iLifetime = 10) {
|
|
|
|
{
|
|
|
|
|
|
|
|
parent::__construct($sTable, $sPrimaryKey, get_parent_class($this), $iLifetime);
|
|
|
|
parent::__construct($sTable, $sPrimaryKey, get_parent_class($this), $iLifetime);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -1379,8 +1314,7 @@ abstract class Item extends cItemBaseAbstract
|
|
|
|
* @param bool $bSafe Use inFilter or not
|
|
|
|
* @param bool $bSafe Use inFilter or not
|
|
|
|
* @return bool True if the load was successful
|
|
|
|
* @return bool True if the load was successful
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public function loadBy($sField, $mValue, $bSafe = true)
|
|
|
|
public function loadBy($sField, $mValue, $bSafe = true) {
|
|
|
|
{
|
|
|
|
|
|
|
|
if ($bSafe) {
|
|
|
|
if ($bSafe) {
|
|
|
|
$mValue = $this->_inFilter($mValue);
|
|
|
|
$mValue = $this->_inFilter($mValue);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1388,9 +1322,9 @@ abstract class Item extends cItemBaseAbstract
|
|
|
|
// check, if cache contains a matching entry
|
|
|
|
// check, if cache contains a matching entry
|
|
|
|
$aRecordSet = null;
|
|
|
|
$aRecordSet = null;
|
|
|
|
if ($sField === $this->primaryKey) {
|
|
|
|
if ($sField === $this->primaryKey) {
|
|
|
|
$aRecordSet = self::$_oCache->getItem($this->table."_".$mValue);
|
|
|
|
$aRecordSet = self::$_oCache->getItem($this->table . "_" . $mValue);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
$aRecordSet = self::$_oCache->getItemByProperty($this->table."_".$sField, $mValue);
|
|
|
|
$aRecordSet = self::$_oCache->getItemByProperty($this->table . "_" . $sField, $mValue);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ($aRecordSet) {
|
|
|
|
if ($aRecordSet) {
|
|
|
@ -1400,9 +1334,8 @@ abstract class Item extends cItemBaseAbstract
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// SQL-Statement to select by field
|
|
|
|
// SQL-Statement to select by field
|
|
|
|
$sql = sprintf("SELECT * FROM `%s` WHERE %s = '%s'",$this->table,$sField,$mValue);
|
|
|
|
$sql = sprintf("SELECT * FROM `%s` WHERE %s = '%s'", $this->table, $sField, $mValue);
|
|
|
|
//$sql = $this->db->prepare($sql, $this->table, $sField, $mValue);
|
|
|
|
//$sql = $this->db->prepare($sql, $this->table, $sField, $mValue);
|
|
|
|
|
|
|
|
|
|
|
|
// Query the database
|
|
|
|
// Query the database
|
|
|
|
$this->db->query($sql);
|
|
|
|
$this->db->query($sql);
|
|
|
|
|
|
|
|
|
|
|
@ -1432,12 +1365,10 @@ abstract class Item extends cItemBaseAbstract
|
|
|
|
* @param string $sWhere The where clause like 'idart = 123 AND idlang = 1'
|
|
|
|
* @param string $sWhere The where clause like 'idart = 123 AND idlang = 1'
|
|
|
|
* @return bool True if the load was successful
|
|
|
|
* @return bool True if the load was successful
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
protected function _loadByWhereClause($sWhere)
|
|
|
|
protected function _loadByWhereClause($sWhere) {
|
|
|
|
{
|
|
|
|
|
|
|
|
// SQL-Statement to select by whee clause
|
|
|
|
// SQL-Statement to select by whee clause
|
|
|
|
$sql = sprintf("SELECT %s AS pk FROM `%s` WHERE ",$this->primaryKey,$this->table) . (string) $sWhere;
|
|
|
|
$sql = sprintf("SELECT %s AS pk FROM `%s` WHERE ", $this->primaryKey, $this->table) . (string) $sWhere;
|
|
|
|
//$sql = $this->db->prepare($sql, $this->primaryKey, $this->table);
|
|
|
|
//$sql = $this->db->prepare($sql, $this->primaryKey, $this->table);
|
|
|
|
|
|
|
|
|
|
|
|
// Query the database
|
|
|
|
// Query the database
|
|
|
|
$this->db->query($sql);
|
|
|
|
$this->db->query($sql);
|
|
|
|
|
|
|
|
|
|
|
@ -1464,8 +1395,7 @@ abstract class Item extends cItemBaseAbstract
|
|
|
|
* @param string $mValue Specifies the primary key value
|
|
|
|
* @param string $mValue Specifies the primary key value
|
|
|
|
* @return bool True if the load was successful
|
|
|
|
* @return bool True if the load was successful
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public function loadByPrimaryKey($mValue)
|
|
|
|
public function loadByPrimaryKey($mValue) {
|
|
|
|
{
|
|
|
|
|
|
|
|
$bSuccess = $this->loadBy($this->primaryKey, $mValue);
|
|
|
|
$bSuccess = $this->loadBy($this->primaryKey, $mValue);
|
|
|
|
|
|
|
|
|
|
|
|
if (($bSuccess == true) && method_exists($this, '_onLoad')) {
|
|
|
|
if (($bSuccess == true) && method_exists($this, '_onLoad')) {
|
|
|
@ -1479,21 +1409,19 @@ abstract class Item extends cItemBaseAbstract
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @param array $aRecordSet The recordset of the item
|
|
|
|
* @param array $aRecordSet The recordset of the item
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public function loadByRecordSet(array $aRecordSet)
|
|
|
|
public function loadByRecordSet(array $aRecordSet) {
|
|
|
|
{
|
|
|
|
|
|
|
|
$this->values = $aRecordSet;
|
|
|
|
$this->values = $aRecordSet;
|
|
|
|
$this->oldPrimaryKey = $this->values[$this->primaryKey];
|
|
|
|
$this->oldPrimaryKey = $this->values[$this->primaryKey];
|
|
|
|
$this->virgin = false;
|
|
|
|
$this->virgin = false;
|
|
|
|
self::$_oCache->addItem($this->table."_".$this->oldPrimaryKey, $this->values);
|
|
|
|
self::$_oCache->addItem($this->table . "_" . $this->oldPrimaryKey, $this->values);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Checks if a the item is already loaded.
|
|
|
|
* Checks if a the item is already loaded.
|
|
|
|
* @return boolean
|
|
|
|
* @return boolean
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public function isLoaded()
|
|
|
|
public function isLoaded() {
|
|
|
|
{
|
|
|
|
return ($this->virgin) ? FALSE : TRUE;
|
|
|
|
return ($this->virgin)?FALSE:TRUE;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -1502,8 +1430,8 @@ abstract class Item extends cItemBaseAbstract
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
protected function _onLoad()
|
|
|
|
protected function _onLoad() {
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -1512,8 +1440,7 @@ abstract class Item extends cItemBaseAbstract
|
|
|
|
* @param string $sField Specifies the field to retrieve
|
|
|
|
* @param string $sField Specifies the field to retrieve
|
|
|
|
* @return mixed Value of the field
|
|
|
|
* @return mixed Value of the field
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public function getField($sField)
|
|
|
|
public function getField($sField) {
|
|
|
|
{
|
|
|
|
|
|
|
|
if ($this->virgin == true) {
|
|
|
|
if ($this->virgin == true) {
|
|
|
|
$this->lasterror = 'No item loaded';
|
|
|
|
$this->lasterror = 'No item loaded';
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
@ -1527,8 +1454,7 @@ abstract class Item extends cItemBaseAbstract
|
|
|
|
* @param string $sField Specifies the field to retrieve
|
|
|
|
* @param string $sField Specifies the field to retrieve
|
|
|
|
* @return mixed Value of the field
|
|
|
|
* @return mixed Value of the field
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public function get($sField)
|
|
|
|
public function get($sField) {
|
|
|
|
{
|
|
|
|
|
|
|
|
return $this->getField($sField);
|
|
|
|
return $this->getField($sField);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -1539,8 +1465,7 @@ abstract class Item extends cItemBaseAbstract
|
|
|
|
* @param string $mValue Value to set
|
|
|
|
* @param string $mValue Value to set
|
|
|
|
* @param bool $bSafe Flag to run defined inFilter on passed value
|
|
|
|
* @param bool $bSafe Flag to run defined inFilter on passed value
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public function setField($sField, $mValue, $bSafe = true)
|
|
|
|
public function setField($sField, $mValue, $bSafe = true) {
|
|
|
|
{
|
|
|
|
|
|
|
|
if ($this->virgin == true) {
|
|
|
|
if ($this->virgin == true) {
|
|
|
|
$this->lasterror = 'No item loaded';
|
|
|
|
$this->lasterror = 'No item loaded';
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
@ -1567,8 +1492,7 @@ abstract class Item extends cItemBaseAbstract
|
|
|
|
* @param string $mValue Value to set
|
|
|
|
* @param string $mValue Value to set
|
|
|
|
* @param bool $bSafe Flag to run defined inFilter on passed value
|
|
|
|
* @param bool $bSafe Flag to run defined inFilter on passed value
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public function set($sField, $mValue, $bSafe = true)
|
|
|
|
public function set($sField, $mValue, $bSafe = true) {
|
|
|
|
{
|
|
|
|
|
|
|
|
return $this->setField($sField, $mValue, $bSafe);
|
|
|
|
return $this->setField($sField, $mValue, $bSafe);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -1578,7 +1502,7 @@ abstract class Item extends cItemBaseAbstract
|
|
|
|
* @return bool
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public function store() {
|
|
|
|
public function store() {
|
|
|
|
if(!$this->isLoaded()) {
|
|
|
|
if (!$this->isLoaded()) {
|
|
|
|
$this->lasterror = 'No item loaded';
|
|
|
|
$this->lasterror = 'No item loaded';
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1606,7 +1530,7 @@ abstract class Item extends cItemBaseAbstract
|
|
|
|
$this->_lastSQL = $sql;
|
|
|
|
$this->_lastSQL = $sql;
|
|
|
|
|
|
|
|
|
|
|
|
if ($this->db->affected_rows() > 0) {
|
|
|
|
if ($this->db->affected_rows() > 0) {
|
|
|
|
self::$_oCache->addItem($this->table."_".$this->oldPrimaryKey, $this->values);
|
|
|
|
self::$_oCache->addItem($this->table . "_" . $this->oldPrimaryKey, $this->values);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return ($this->db->affected_rows() < 1) ? false : true;
|
|
|
|
return ($this->db->affected_rows() < 1) ? false : true;
|
|
|
@ -1617,8 +1541,7 @@ abstract class Item extends cItemBaseAbstract
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @return array|false
|
|
|
|
* @return array|false
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public function toArray()
|
|
|
|
public function toArray() {
|
|
|
|
{
|
|
|
|
|
|
|
|
if ($this->virgin == true) {
|
|
|
|
if ($this->virgin == true) {
|
|
|
|
$this->lasterror = 'No item loaded';
|
|
|
|
$this->lasterror = 'No item loaded';
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
@ -1636,8 +1559,7 @@ abstract class Item extends cItemBaseAbstract
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @return stdClass|false
|
|
|
|
* @return stdClass|false
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public function toObject()
|
|
|
|
public function toObject() {
|
|
|
|
{
|
|
|
|
|
|
|
|
$return = $this->toArray();
|
|
|
|
$return = $this->toArray();
|
|
|
|
return (false !== $return) ? (object) $return : $return;
|
|
|
|
return (false !== $return) ? (object) $return : $return;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1650,8 +1572,7 @@ abstract class Item extends cItemBaseAbstract
|
|
|
|
* @param mixed $mValue Specifies the value
|
|
|
|
* @param mixed $mValue Specifies the value
|
|
|
|
* @return bool
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public function setProperty($sType, $sName, $mValue)
|
|
|
|
public function setProperty($sType, $sName, $mValue) {
|
|
|
|
{
|
|
|
|
|
|
|
|
// If this object wasn't loaded before, return false
|
|
|
|
// If this object wasn't loaded before, return false
|
|
|
|
if ($this->virgin == true) {
|
|
|
|
if ($this->virgin == true) {
|
|
|
|
$this->lasterror = 'No item loaded';
|
|
|
|
$this->lasterror = 'No item loaded';
|
|
|
@ -1673,8 +1594,7 @@ abstract class Item extends cItemBaseAbstract
|
|
|
|
* @param string $sName Specifies the name
|
|
|
|
* @param string $sName Specifies the name
|
|
|
|
* @return mixed Value of the given property or false
|
|
|
|
* @return mixed Value of the given property or false
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public function getProperty($sType, $sName)
|
|
|
|
public function getProperty($sType, $sName) {
|
|
|
|
{
|
|
|
|
|
|
|
|
// If this object wasn't loaded before, return false
|
|
|
|
// If this object wasn't loaded before, return false
|
|
|
|
if ($this->virgin == true) {
|
|
|
|
if ($this->virgin == true) {
|
|
|
|
$this->lasterror = 'No item loaded';
|
|
|
|
$this->lasterror = 'No item loaded';
|
|
|
@ -1696,8 +1616,7 @@ abstract class Item extends cItemBaseAbstract
|
|
|
|
* @param string $sName Specifies the name
|
|
|
|
* @param string $sName Specifies the name
|
|
|
|
* @return bool
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public function deleteProperty($sType, $sName)
|
|
|
|
public function deleteProperty($sType, $sName) {
|
|
|
|
{
|
|
|
|
|
|
|
|
// If this object wasn't loaded before, return false
|
|
|
|
// If this object wasn't loaded before, return false
|
|
|
|
if ($this->virgin == true) {
|
|
|
|
if ($this->virgin == true) {
|
|
|
|
$this->lasterror = 'No item loaded';
|
|
|
|
$this->lasterror = 'No item loaded';
|
|
|
@ -1718,8 +1637,7 @@ abstract class Item extends cItemBaseAbstract
|
|
|
|
* @param int $idprop Id of property
|
|
|
|
* @param int $idprop Id of property
|
|
|
|
* @return bool
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public function deletePropertyById($idprop)
|
|
|
|
public function deletePropertyById($idprop) {
|
|
|
|
{
|
|
|
|
|
|
|
|
$oProperties = $this->_getPropertiesCollectionInstance();
|
|
|
|
$oProperties = $this->_getPropertiesCollectionInstance();
|
|
|
|
return $oProperties->delete($idprop);
|
|
|
|
return $oProperties->delete($idprop);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1750,8 +1668,7 @@ abstract class Item extends cItemBaseAbstract
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public function setFilters($aInFilters = array(), $aOutFilters = array())
|
|
|
|
public function setFilters($aInFilters = array(), $aOutFilters = array()) {
|
|
|
|
{
|
|
|
|
|
|
|
|
$this->_arrInFilters = $aInFilters;
|
|
|
|
$this->_arrInFilters = $aInFilters;
|
|
|
|
$this->_arrOutFilters = $aOutFilters;
|
|
|
|
$this->_arrOutFilters = $aOutFilters;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1767,7 +1684,8 @@ abstract class Item extends cItemBaseAbstract
|
|
|
|
* @return mixed Filtered data
|
|
|
|
* @return mixed Filtered data
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public function _inFilter($mData) {
|
|
|
|
public function _inFilter($mData) {
|
|
|
|
if(is_numeric($mData) || is_array($mData)) return $mData;
|
|
|
|
if (is_numeric($mData) || is_array($mData))
|
|
|
|
|
|
|
|
return $mData;
|
|
|
|
|
|
|
|
|
|
|
|
foreach ($this->_arrInFilters as $_function) {
|
|
|
|
foreach ($this->_arrInFilters as $_function) {
|
|
|
|
if (function_exists($_function)) {
|
|
|
|
if (function_exists($_function)) {
|
|
|
@ -1786,7 +1704,8 @@ abstract class Item extends cItemBaseAbstract
|
|
|
|
* @return mixed Filtered data
|
|
|
|
* @return mixed Filtered data
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
protected function _outFilter($mData) {
|
|
|
|
protected function _outFilter($mData) {
|
|
|
|
if(is_numeric($mData)) return $mData;
|
|
|
|
if (is_numeric($mData))
|
|
|
|
|
|
|
|
return $mData;
|
|
|
|
|
|
|
|
|
|
|
|
foreach ($this->_arrOutFilters as $_function) {
|
|
|
|
foreach ($this->_arrOutFilters as $_function) {
|
|
|
|
if (function_exists($_function)) {
|
|
|
|
if (function_exists($_function)) {
|
|
|
@ -1796,13 +1715,11 @@ abstract class Item extends cItemBaseAbstract
|
|
|
|
return $mData;
|
|
|
|
return $mData;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected function _setMetaObject($sObjectName)
|
|
|
|
protected function _setMetaObject($sObjectName) {
|
|
|
|
{
|
|
|
|
|
|
|
|
$this->_metaObject = $sObjectName;
|
|
|
|
$this->_metaObject = $sObjectName;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function getMetaObject()
|
|
|
|
public function getMetaObject() {
|
|
|
|
{
|
|
|
|
|
|
|
|
global $_metaObjectCache;
|
|
|
|
global $_metaObjectCache;
|
|
|
|
|
|
|
|
|
|
|
|
if (!is_array($_metaObjectCache)) {
|
|
|
|
if (!is_array($_metaObjectCache)) {
|
|
|
@ -1822,10 +1739,9 @@ abstract class Item extends cItemBaseAbstract
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (class_exists($sClassName)) {
|
|
|
|
if (class_exists($sClassName)) {
|
|
|
|
$_metaObjectCache[$qclassname] = new $sClassName ($this);
|
|
|
|
$_metaObjectCache[$qclassname] = new $sClassName($this);
|
|
|
|
return $_metaObjectCache[$qclassname];
|
|
|
|
return $_metaObjectCache[$qclassname];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
|