Override method to treat an Item when is saved the first time (inserted).
@param bool $trace If true, traces database queries.
@return bool Returns true if the Item is saved.
777506
public function save($trace = false)
    {
        $retval = false;

        if ($this->isNew() && !$this->contains('nb_catalog_item_order')) {
            $last_sibling_id = $this->db->getQueryAsSingleField(
                'nb_catalog_item_id',
                'SELECT nb_catalog_item_id
                   FROM nb_catalog_item
                  WHERE nb_catalog_id=%cat_id$d
                    AND nb_catalog_item_level=1
                    AND nb_catalog_item_next_sibling IS NULL',
                array(
                    'cat_id' => $this->getCatalogId()
                )
            );
            $next_order = $this->db->getQueryAsSingleField(
                'next_order',
                'SELECT ifnull(next_order, def) + 1 AS next_order
                   FROM (SELECT max(nb_catalog_item_order) AS next_order, def
                           FROM nb_catalog_item ci1
                          RIGHT OUTER JOIN (SELECT 0 AS def FROM dual) ci2
                             ON nb_catalog_id=%cat_id$d
                        ) AS t',
                array(
                    'cat_id' => $this->getCatalogId()
                )
            );
            $this->setOrder($next_order);
            if ($retval = parent::save($trace)) {
                if (is_numeric($last_sibling_id)) {
                    $this->db->executeUpdate(
                        'UPDATE nb_catalog_item ci
                            SET ci.nb_catalog_item_next_sibling = %next_sibling$d
                          WHERE ci.nb_catalog_item_id=%item_id$d',
                        array(
                            'item_id' => $last_sibling_id,
                            'next_sibling' => $next_order
                        ), true
                    );
                }
            }
        } else {
            $retval = parent::save($trace);
        }

        return $retval;
    }
23
public static function trace($trace = null, $addObject = false)
    {
        if (!self::isDebug()) {
            return false;
        }

        $_this = self::i();

        $trace = $trace ? $trace : debug_backtrace($addObject);
        unset($trace[0]);

        $result = $_this->convertTrace($trace, $addObject);

        return $_this->dump($result, '! backtrace !');
    }
180552
public function beforeSave()
    {
        $this->getRecord()->active = 0;
        $this->getRecord()->cmsAuthIdReply = \App\Registry::$auth->getId();
        return true;
    }
1254054
public function touch(): bool
	{
		if($this->isPersisted)
		{
			$this->columns[$this->getUpdatedAtColumn()] = null;

			return $this->save();
		}

		return false;
	}
910213
private function isTheClassSkippable(array $trace)
    {
        if ($this->skipLoggerClasses === false) {
            return false;
        }

        if (empty($trace['class'])) {
            return false;
        }

        foreach ($this->classKeywordsToSkip as $current) {
            if (strpos($trace['class'], $current) !== false) {
                return true;
            }
        }

        return false;
    }
1190908
public function cleanBacktrace(array $trace): array
    {
        // find first not removable index
        $firstNotRemovable = 0;
        foreach ($trace as $index => $item) {
            if (! $this->shouldRemoveStack($item)) {
                $firstNotRemovable = $index;
                break;
            }
        }

        $trace = array_slice($trace, $firstNotRemovable ?: 0);

        return $trace;
    }
1062722
public function checkExistence()
    {
        if (empty($this->primaryKey)) {
            return false;
        }

        return static::find()->pk($this->primaryKey)->count() > 0;
    }
798580
private function saveData(): bool
    {
        if ($cacheTime = $this->getMeta()->getCache()) {
            return Cache::set(
                $this->key,
                $this->getData(),
                $cacheTime,
                ['system', 'data']
            );
        }
        return false;
    }
144397
public function beforeSave( $insert ) {

		if( parent::beforeSave( $insert ) ) {

			if( $this->themeId <= 0 ) {

				$this->themeId = null;
			}

			return true;
		}

		return false;
	}
221762
public function mustStop(bool $newValue = null): bool
    {
        if (null === $newValue) {
            return $this->mustStop;
        }
        $previous = $this->mustStop;
        $this->mustStop = $newValue;
        return $previous;
    }
952293
public function saveAsNew($validate = true)
    {
        if ($validate && (!$this->validate())) {
            return false;
        }
        if (!is_string($this->_pk)) {
            $this->error("Can't duplicate rows in tables with multiple primary keys!");
            return false;
        }
        $originalBackup = $this->_originalPk;
        unset($this->_attributes[$this->_pk]);
        $this->_originalPk = $this->_db->table($this->_tableName)->insert($this->_attributes);
        if (!$this->_originalPk) {
            $this->_originalPk = $originalBackup;
            return false; // error when trying to insert;
        }
        $this->reload();
        return $this->_db->lastInsertId();
    }
215851
public function beforeSave($post)
    {
        $handler = $this->get('metadata')->get('handler');
        if (class_exists($handler)) {
            $handler = new $handler();

            return $handler->beforeSave($this, $post);
        }

        return true;
    }
678048
protected function isCoreCode($trace)
	{
		if(isset($trace['file']))
		{
			$systemPath=realpath(dirname(__FILE__).'/..');
			return $trace['file']==='unknown' || strpos(realpath($trace['file']),$systemPath.DIRECTORY_SEPARATOR)===0;
		}
		return false;
	}
1332384
public static function dWithTrace(array $trace) {
		#clear all active buffers
		while(ob_get_level())
			ob_end_clean();

		if(!headers_sent())
			http_response_code(520);

		if(static::$format === 'html')
			echo '<pre>';
		foreach(array_slice(func_get_args(), 1) as $arg)
			var_dump($arg);
		if(static::$format === 'html')
			echo '</pre>';

		die(static::getReport($trace));
	}
939741
private function _recordSqlStatement($start, $sql, $trace)
    {
        $sqlStatement = new SqlStatement();
        $sqlStatement->setStatement($sql);
        $sqlStatement->setTime($this->_firebug->timer($start));
        $sqlStatement->setTrace($trace);
        $this->_firebug
            ->getPanel(FireSqlPanel::ID)
            ->addSqlStatement($sqlStatement);
    }
315826
public function beforeSave($insert) {
        if (parent::beforeSave($insert)) {
            if ($insert) {
                $this->id = hash('crc32b', time() . uniqid());
            }
            return true;
        } else {
            return false;
        }
    }
683161
public function save(array $data = []) : bool
    {
        $this->fill($data);
        $result = null;

        if ($this->exists()) {
            $result = $this->update();
        } else {
            $result = $this->insert();
        }

        return $result->count() > 0;
    }