public function checkin()
	{
		if (!$this->isNew())
		{
			$columns = $this->getStructure()->getTableColumns($this->getTableName(), false);

			$data = [];
			$orig = [];
			foreach ($columns as $column)
			{
				// We want to get the default values from the
				// table's schema, rather than assuming
				if ($column['name'] == 'checked_out_time')
				{
					$orig['checked_out_time'] = $this->get('checked_out_time');
					$data['checked_out_time'] = $column['default'];
				}

				if ($column['name'] == 'checked_out')
				{
					$orig['checked_out'] = $this->get('checked_out');
					$data['checked_out'] = $column['default'];
				}
			}

			if (empty($data))
			{
				// There is no 'checked_out_time' or 'checked_out' column
				return true;
			}

			$this->set($data);

			// We build a simple update query as calling save()
			// can have unintended consequences when all we want
			// is to update two columns
			$query = $this->getQuery()
				->update($this->getTableName())
				->set($data)
				->whereEquals($this->getPrimaryKey(), $this->get($this->getPrimaryKey()));

			// @FIXME: Maybe unnecessary? Database may throw an exception on error
			//         so this might be pointless.
			if (!$query->execute())
			{
				// Reset to original data
				$this->set($orig);

				$this->addError(__CLASS__ . '::' . __METHOD__ . '() failed');
				return false;
			}
		}

		return true;
	}
public function checkin()
	{
		if (!$this->isNew())
		{
			$columns = $this->getStructure()->getTableColumns($this->getTableName(), false);

			$data = [];
			$orig = [];
			foreach ($columns as $column)
			{
				// We want to get the default values from the
				// table's schema, rather than assuming
				if ($column['name'] == 'checked_out_time')
				{
					$orig['checked_out_time'] = $this->get('checked_out_time');
					$data['checked_out_time'] = $column['default'];
				}

				if ($column['name'] == 'checked_out')
				{
					$orig['checked_out'] = $this->get('checked_out');
					$data['checked_out'] = $column['default'];
				}
			}

			if (empty($data))
			{
				// There is no 'checked_out_time' or 'checked_out' column
				return true;
			}

			$this->set($data);

			// We build a simple update query as calling save()
			// can have unintended consequences when all we want
			// is to update two columns
			$query = $this->getQuery()
				->update($this->getTableName())
				->set($data)
				->whereEquals($this->getPrimaryKey(), $this->get($this->getPrimaryKey()));

			// @FIXME: Maybe unnecessary? Database may throw an exception on error
			//         so this might be pointless.
			if (!$query->execute())
			{
				// Reset to original data
				$this->set($orig);

				$this->addError(__CLASS__ . '::' . __METHOD__ . '() failed');
				return false;
			}
		}

		return true;
	}
public function checkin ( ) { if ( ! $ this -> isNew ( ) ) { $ columns = $ this -> getStructure ( ) -> getTableColumns ( $ this -> getTableName ( ) , false ) ; $ data = [ ] ; $ orig = [ ] ; foreach ( $ columns as $ column ) { // We want to get the default values from the // table's schema, rather than assuming if ( $ column [ 'name' ] == 'checked_out_time' ) { $ orig [ 'checked_out_time' ] = $ this -> get ( 'checked_out_time' ) ; $ data [ 'checked_out_time' ] = $ column [ 'default' ] ; } if ( $ column [ 'name' ] == 'checked_out' ) { $ orig [ 'checked_out' ] = $ this -> get ( 'checked_out' ) ; $ data [ 'checked_out' ] = $ column [ 'default' ] ; } } if ( empty ( $ data ) ) { // There is no 'checked_out_time' or 'checked_out' column return true ; } $ this -> set ( $ data ) ; // We build a simple update query as calling save() // can have unintended consequences when all we want // is to update two columns $ query = $ this -> getQuery ( ) -> update ( $ this -> getTableName ( ) ) -> set ( $ data ) -> whereEquals ( $ this -> getPrimaryKey ( ) , $ this -> get ( $ this -> getPrimaryKey ( ) ) ) ; // @FIXME: Maybe unnecessary? Database may throw an exception on error //         so this might be pointless. if ( ! $ query -> execute ( ) ) { // Reset to original data $ this -> set ( $ orig ) ; $ this -> addError ( __CLASS__ . '::' . __METHOD__ . '() failed' ) ; return false ; } } return true ; }
Checks back in the current model

@return  boolean
@since   2.0.0
Checks back in the current model