src/Resource.php
public function load($id = null) {
		// fill the object with blank properties based on the fields of that table
		$fields = $this->fields();
		foreach ($fields as $key => $field) {
			$this->{$key} = $this->{$key} ? $this->{$key} : '';
		}

		if (!$id && $this->dbId()) {
			$id = $this->dbId();
		}

		if (is_object($id)) {
			$node = $id;

		} elseif (is_array($id)) {
			$node = (object)$id;

		} elseif ($id) {
			if (!$node) {
				$node = (object)$this->db()->get('select * from `' . $this->table() . '` where `'.$this->idVar().'` = ? limit 1', [$id])[0];
			}
		}

		if (!$node) {
			$node = new Model;
		}

		if (isset($node)) {
			foreach(get_object_vars($node) as $var => $value) {
				$this->$var = $value;
			}
		}

		foreach ($this->fields() as $field) {
			switch ($field->type) {
				case 'int':
					$this->{$field->field} = (int)$this->{$field->field};
					break;
				case 'boolean':
					$this->{$field->field} = $this->{$field->field} ? true : false;
					break;
			}
		}

		if ($this->tipsy() && $this->tipsy()->config()['tipsy']['factory'] !== false) {
			$this->tipsy()->factory($this);
		}

		return $this;
	}
public function load($id = null) {
		// fill the object with blank properties based on the fields of that table
		$fields = $this->fields();
		foreach ($fields as $key => $field) {
			$this->{$key} = $this->{$key} ? $this->{$key} : '';
		}

		if (!$id && $this->dbId()) {
			$id = $this->dbId();
		}

		if (is_object($id)) {
			$node = $id;

		} elseif (is_array($id)) {
			$node = (object)$id;

		} elseif ($id) {
			if (!$node) {
				$node = (object)$this->db()->get('select * from `' . $this->table() . '` where `'.$this->idVar().'` = ? limit 1', [$id])[0];
			}
		}

		if (!$node) {
			$node = new Model;
		}

		if (isset($node)) {
			foreach(get_object_vars($node) as $var => $value) {
				$this->$var = $value;
			}
		}

		foreach ($this->fields() as $field) {
			switch ($field->type) {
				case 'int':
					$this->{$field->field} = (int)$this->{$field->field};
					break;
				case 'boolean':
					$this->{$field->field} = $this->{$field->field} ? true : false;
					break;
			}
		}

		if ($this->tipsy() && $this->tipsy()->config()['tipsy']['factory'] !== false) {
			$this->tipsy()->factory($this);
		}

		return $this;
	}
public function load ( $ id = null ) { // fill the object with blank properties based on the fields of that table $ fields = $ this -> fields ( ) ; foreach ( $ fields as $ key => $ field ) { $ this -> { $ key } = $ this -> { $ key } ? $ this -> { $ key } : '' ; } if ( ! $ id && $ this -> dbId ( ) ) { $ id = $ this -> dbId ( ) ; } if ( is_object ( $ id ) ) { $ node = $ id ; } elseif ( is_array ( $ id ) ) { $ node = ( object ) $ id ; } elseif ( $ id ) { if ( ! $ node ) { $ node = ( object ) $ this -> db ( ) -> get ( 'select * from `' . $ this -> table ( ) . '` where `' . $ this -> idVar ( ) . '` = ? limit 1' , [ $ id ] ) [ 0 ] ; } } if ( ! $ node ) { $ node = new Model ; } if ( isset ( $ node ) ) { foreach ( get_object_vars ( $ node ) as $ var => $ value ) { $ this -> $ var = $ value ; } } foreach ( $ this -> fields ( ) as $ field ) { switch ( $ field -> type ) { case 'int' : $ this -> { $ field -> field } = ( int ) $ this -> { $ field -> field } ; break ; case 'boolean' : $ this -> { $ field -> field } = $ this -> { $ field -> field } ? true : false ; break ; } } if ( $ this -> tipsy ( ) && $ this -> tipsy ( ) -> config ( ) [ 'tipsy' ] [ 'factory' ] !== false ) { $ this -> tipsy ( ) -> factory ( $ this ) ; } return $ this ; }
Load the object with properties

Passing in an object will populate $this with the current vars of that object
as public properties. Passing in an int id will load the object with the
table and key associated with the object.

@param $id object|int
Load the object with properties