Skip to content

Commit

Permalink
Testing in progress
Browse files Browse the repository at this point in the history
  • Loading branch information
rotexdegba committed Dec 23, 2022
1 parent 66fcc9e commit 896ce28
Showing 1 changed file with 5 additions and 46 deletions.
51 changes: 5 additions & 46 deletions src/GDAO/Model/RecordInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ interface RecordInterface extends \ArrayAccess, \Countable, \IteratorAggregate
////////////////////////////////////////////////////////////////////////////

/**
*
* @param array $data associative array of data to be loaded into this record.
* [
* 'col_name1'=>'value_for_col1',
Expand All @@ -84,7 +83,6 @@ interface RecordInterface extends \ArrayAccess, \Countable, \IteratorAggregate
public function __construct(array $data, \GDAO\Model $model);

/**
*
* Delete the record from the db.
*
* If deletion was successful and the primary key column for the record's db
Expand All @@ -97,12 +95,10 @@ public function __construct(array $data, \GDAO\Model $model);
* @param bool $set_record_objects_data_to_empty_array true to reset the record object's data to an empty array if db deletion was successful, false to keep record object's data
*
* @return bool true if record was successfully deleted from db or false if not
*
*/
public function delete($set_record_objects_data_to_empty_array=false): bool;

/**
*
* Get the data for this record.
* Modifying the returned data will not affect the data inside this record.
*
Expand All @@ -111,17 +107,15 @@ public function delete($set_record_objects_data_to_empty_array=false): bool;
public function getData(): array;

/**
*
* Get a copy of the initial data loaded into this record.
* Modifying the returned data will not affect the initial data inside this record.
*
* @return null|array a copy of the initial data loaded into this record.
* @return array a copy of the initial data loaded into this record.
*/
public function getInitialData(): ?array;
public function getInitialData(): array;


/**
*
* Get all the related data loaded into this record.
* Modifying the returned data will not affect the related data inside this record.
*
Expand All @@ -130,15 +124,13 @@ public function getInitialData(): ?array;
public function getRelatedData(): array;

/**
*
* Get data for this record that does not belong to any of it's table columns and is not related data.
*
* @return array Data for this record (not to be saved to the db i.e. not from any actual db column and not related data).
*/
public function getNonTableColAndNonRelatedData(): array;

/**
*
* Get a reference to the data for this record.
* Modifying the returned data will affect the data inside this record.
*
Expand All @@ -147,16 +139,14 @@ public function getNonTableColAndNonRelatedData(): array;
public function &getDataByRef(): array;

/**
*
* Get a reference to the initial data loaded into this record.
* Modifying the returned data will affect the initial data inside this record.
*
* @return null|array a reference to the initial data loaded into this record.
* @return array a reference to the initial data loaded into this record.
*/
public function &getInitialDataByRef(): ?array;
public function &getInitialDataByRef(): array;

/**
*
* Get a reference to all the related data loaded into this record.
* Modifying the returned data will affect the related data inside this record.
*
Expand All @@ -165,15 +155,13 @@ public function &getInitialDataByRef(): ?array;
public function &getRelatedDataByRef(): array;

/**
*
* Get data for this record that does not belong to any of it's table columns and is not related data.
*
* @return array reference to the data for this record (not from any actual db column and not related data).
*/
public function &getNonTableColAndNonRelatedDataByRef(): array;

/**
*
* Set relation data for this record.
*
* @param string $key relation name
Expand All @@ -186,46 +174,37 @@ public function &getNonTableColAndNonRelatedDataByRef(): array;
public function setRelatedData($key, $value): self;

/**
*
* Get the model object that saves and reads data to and from the db on
* behalf of this record
* Get the model object that saves and reads data to and from the db on behalf of this record
*/
public function getModel(): \GDAO\Model;

/**
*
* @return string name of the primary-key column of the db table this record belongs to
*/
public function getPrimaryCol(): string;

/**
*
* @return mixed the value stored in the primary-key column for this record.
*/
public function getPrimaryVal();

/**
*
* Tells if the record, or a particular table-column in the record, has
* changed from its initial value.
*
* @param string $col The table-column name.
*
* @return null|bool Returns null if the table-column name does not exist,
* boolean true if the data is changed, boolean false if not changed.
*
*/
public function isChanged($col = null): ?bool;

/**
*
* Is the record new? (I.e. its data has never been saved to the db)
*
*/
public function isNew(): bool;

/**
*
* This method partially or completely overwrites pre-existing data for a
* record and replaces it with the new data (this does not include related
* data). If no data has previously been loaded into the record, keep a copy
Expand All @@ -251,7 +230,6 @@ public function isNew(): bool;
public function loadData($data_2_load, array $cols_2_load = []): self;

/**
*
* Set the _is_new attribute of this record to true (meaning that the data
* for this record has never been saved to the db).
*
Expand All @@ -260,7 +238,6 @@ public function loadData($data_2_load, array $cols_2_load = []): self;
public function markAsNew(): self;

/**
*
* Set the _is_new attribute of this record to false (meaning that the data
* for this record has been saved to the db or was read from the db).
*
Expand Down Expand Up @@ -288,20 +265,17 @@ public function markAsNotNew(): self;
public function setStateToNew(): self;

/**
*
* Save the specified or already existing data for this record to the db.
* Since this record can only talk to the db via its model property (_model)
* the save operation will actually be done via $this->model.
*
* @param \GDAO\Model\RecordInterface|array $data_2_save
*
* @return null|bool true: successful save, false: failed save, null: no changed data to save
*
*/
public function save($data_2_save = null): ?bool;

/**
*
* Save the specified or already existing data for this record to the db.
* Since this record can only talk to the db via its model property (_model)
* the save operation will actually be done via $this->model.
Expand All @@ -314,82 +288,67 @@ public function save($data_2_save = null): ?bool;
* @param \GDAO\Model\RecordInterface|array $data_2_save
*
* @return bool|null true for a successful save, false for failed save, null: no changed data to save
*
*/
public function saveInTransaction($data_2_save = null): ?bool;

/**
*
* Set the \GDAO\Model object for this record
*
* @param \GDAO\Model $model
*
* @return $this
*/
public function setModel(\GDAO\Model $model): self;

/**
*
* Get all the data and property (name & value pairs) for this record.
*
* @return array of all data & property (name & value pairs) for this record.
*
*/
public function toArray(): array;

//Magic Methods

/**
*
* Gets a data value.
*
* @param string $key The requested data key.
*
* @return mixed The data value.
*
*/
public function __get($key);

/**
*
* Does a certain key exist in the data?
*
* Note that this is slightly different from normal PHP isset(); it will
* say the key is set, even if the key value is null or otherwise empty.
*
* @param string $key The requested data key.
*
*/
public function __isset($key): bool;

/**
*
* Sets a key value.
*
* @param string $key The requested data key.
*
* @param mixed $val The value to set the data to.
*
*/
public function __set($key, $val): void;

/**
*
* Get the string representation of all the data and property
* (name & value pairs) for this record.
*
* @return string string representation of all the data & property
* (name & value pairs) for this record.
*
*/
public function __toString(): string;

/**
*
* Removes a key and its value in the data.
*
* @param string $key The requested data key.
*
*/
public function __unset($key): void;
}

0 comments on commit 896ce28

Please sign in to comment.