AlexBraun
Новичок
Доброго время суток.
После обновления PHP с 4.3.8 до 5.2.17 перестал работать сайт.
Вылазит следующая ошибка:
Fatal error: Cannot call __clone() method on objects - use 'clone $obj' instead in /var/www/data/www/local2.ru/lib/DB_DataObjectE.php on line 19
Сам файл DB_DataObjectE.php :
	
	
	
		
Я так понимаю ошибка в месте $obj = $this->__clone(); ? Как можно подправить?
								После обновления PHP с 4.3.8 до 5.2.17 перестал работать сайт.
Вылазит следующая ошибка:
Fatal error: Cannot call __clone() method on objects - use 'clone $obj' instead in /var/www/data/www/local2.ru/lib/DB_DataObjectE.php on line 19
Сам файл DB_DataObjectE.php :
		PHP:
	
	<?php
require_once 'DB/DataObject.php';
class DB_DataObjectE extends DB_DataObject {
    /**
     * fetch all objects using fetch() method
     *
	 * return array containing all fetched objects
	 *
     * @access public
     * @return array
     */
    function fetchall($group = '', $key = null, $renumber = false) {
		$all = array();
		$prev_key = null;
		while($this->fetch()) {
			if(!empty($group)) {
				$obj = $this->__clone();
				if($obj->$group !== null) {
					if($key && $obj->$key) {
						$all[$obj->$group][$obj->$key] = $obj;
					} else {
						$all[$obj->$group][] = $obj;
					}
				}
				unset($obj);
			} else {
				$all[] = $this->__clone();
			}
		}
		if($renumber) {
			#foreach($all as $a) {
			#	$tmp[] = $a;
			#}
			#$all = $tmp;
			#unset($tmp);
			#sort($all);
		}
		return $all;
    }
    /**
     * fetch all objects using fetch() method into associative array
     *
	 * return associative array containing all fetched objects
	 *
     * @access public
     * @return array
     */
	function fetchAllById() {
		$all = array();
		while($this->fetch()) {
			$all[$this->id] = $this->__clone();
		}
		return $all;
	}
	/**
	 * Выбираем идентификаторы
	 *
	 * @return unknown
	 */
	function getMainIds() {
		global $_DB_DATAOBJECT;
        if (is_bool($countWhat)) {
            $whereAddOnly = $countWhat;
        }
        $t = clone($this);
        $quoteIdentifiers = !empty($_DB_DATAOBJECT['CONFIG']['quote_identifiers']);
        $items   = $t->table();
        if (!isset($t->_query)) {
            $this->raiseError(
                "You cannot do run count after you have run fetch()",
                DB_DATAOBJECT_ERROR_INVALIDARGS);
            return false;
        }
        $this->_connect();
        $DB = &$_DB_DATAOBJECT['CONNECTIONS'][$this->_database_dsn_md5];
        if (!$whereAddOnly && $items)  {
            $t->_build_condition($items);
        }
        $keys = $this->keys();
        if (!$keys[0] && !is_string($countWhat)) {
            $this->raiseError(
                "You cannot do run count without keys - use \$do->keys('id');",
                DB_DATAOBJECT_ERROR_INVALIDARGS,PEAR_ERROR_DIE);
            return false;
        }
        $table   = ($quoteIdentifiers ? $DB->quoteIdentifier($this->__table) : $this->__table);
        $key_col = ($quoteIdentifiers ? $DB->quoteIdentifier($keys[0]) : $keys[0]);
        $as      = ($quoteIdentifiers ? $DB->quoteIdentifier('DATAOBJECT_NUM') : 'DATAOBJECT_NUM');
        // support distinct on default keys.
        $countWhat = "DISTINCT {$table}.{$key_col}";
        $sql = "SELECT {$countWhat} as $as
                FROM $table {$t->_join} {$t->_query['condition']}";
        $sql = $DB->modifyLimitQuery($sql,$this->_query['limit_start'], $this->_query['limit_count']);
        $r = $t->_query($sql);
        if (PEAR::isError($r)) {
            return false;
        }
        $result  = &$_DB_DATAOBJECT['RESULTS'][$t->_DB_resultid];
        while ($l = $result->fetchRow()) {
        	$arr[] = $l[0];
        }
        return $arr;
	}
	/**
	 * Ограничитель для слинкованных таблиц
	 *
	 * @param unknown_type $start
	 * @param unknown_type $offset
	 */
	function limitJoined($start, $offset) {
		$this->limit($start, $offset);
		$DB = &$_DB_DATAOBJECT['CONNECTIONS'][$this->_database_dsn_md5];
		$keys = $this->keys();
		$table   = ($quoteIdentifiers ? $DB->quoteIdentifier($this->__table) : $this->__table);
        $key_col = ($quoteIdentifiers ? $DB->quoteIdentifier($keys[0]) : $keys[0]);
        $ids = $this->getMainIds();
        if (count($ids) < 1) {
        	$this->whereAdd("{$table}.{$key_col} < 0");
        } else {
        	$this->whereAdd("{$table}.{$key_col} IN (".implode(',', $this->getMainIds()).")");
        }
		$this->limit();
	}
}
?> 
	            
 
 
		 
 
		 
 
		 
 
		