NodeDao
namespace |
bhenk\msdata\node |
predicates |
Cloneable | Instantiable |
extends |
|
hierarchy |
Constants
NodeDao::TABLE_NAME
predicates |
public |
string(8) "tbl_node"
Methods
NodeDao::getDataObjectName
predicates |
public |
implements |
public function getDataObjectName(): string
NodeDao::getTableName
predicates |
public |
implements |
public function getTableName(): string
NodeDao::selectChildren
predicates |
public |
public function selectChildren(
Parameter #0 [ <required> int $ID ]
): array
NodeDao::selectGenerationNumbers
predicates |
public |
public function selectGenerationNumbers(): array
NodeDao::dropTable
predicates |
public |
inherited from |
Drop table if it exists
Tries to drop the table with the name returned by AbstractDao::getTableName.
public function dropTable(): bool
NodeDao::createTable
predicates |
public |
inherited from |
Create a table in the database
The statement used is the one from getCreateTableStatement.
public function createTable(
Parameter #0 [ <optional> bool $drop = false ]
): int
NodeDao::getCreateTableStatement
predicates |
public |
inherited from |
Produces a minimal CreateTableStatement
CREATE TABLE IF NOT EXISTS `%table_name%`
(
`ID` INT NOT NULL AUTO_INCREMENT,
`%int_prop%` INT,
`%string_prop%` VARCHAR(255),
`%bool_prop%` BOOLEAN,
`%float_prop%` FLOAT,
PRIMARY KEY (`ID`)
);
In the above %xyz% is placeholder for table name or property name. Notice that string type parameters have a limited length of 255 characters.
Subclasses may override. The table MUST have the same name as the one returned by the method getTableName.
public function getCreateTableStatement(): string
NodeDao::insert
predicates |
public |
inherited from |
Insert the given Entity
With $insertID set to false (this is the default), the ID of the Entity (if any) will be ignored. Returns an Entity equal to the given Entity with the new ID.
In order to be able to reconstruct a table, the ID of the Entity can be inserted as well. Set $insertID to true to achieve this.
public function insert(
Parameter #0 [ <required> bhenk\msdata\abc\Entity $entity ]
Parameter #1 [ <optional> bool $insertID = false ]
): Entity
NodeDao::insertBatch
predicates |
public |
inherited from |
Insert the Entities from the given array
The ID of the Entity (if any) will be ignored. Returns an array of Entities equal to the given Entities with new IDs and ID as array key. This default behaviour can be altered by providing a closure that receives each inserted entity and decides what key will be returned:
$func = function(Entity $entity): int {
return $entity->getID();
};
In order to be able to reconstruct a table, the ID of the Entities can be inserted as well. Set $insertID to true to achieve this.
public function insertBatch(
Parameter #0 [ <required> array $entity_array ]
Parameter #1 [ <optional> ?Closure $func = NULL ]
Parameter #2 [ <optional> bool $insertID = false ]
): array
NodeDao::update
predicates |
public |
inherited from |
Update the given Entity
public function update(
Parameter #0 [ <required> bhenk\msdata\abc\Entity $entity ]
): int
NodeDao::updateBatch
predicates |
public |
inherited from |
Update the Entities in the given array
public function updateBatch(
Parameter #0 [ <required> array $entity_array ]
): int
NodeDao::delete
predicates |
public |
inherited from |
Delete the row with the given ID
public function delete(
Parameter #0 [ <required> int $ID ]
): int
NodeDao::deleteBatch
predicates |
public |
inherited from |
Delete rows with the given IDs
public function deleteBatch(
Parameter #0 [ <required> array $ids ]
): int
NodeDao::select
predicates |
public |
inherited from |
Fetch the Entity with the given ID
public function select(
Parameter #0 [ <required> int $ID ]
): ?Entity
NodeDao::selectBatch
predicates |
public |
inherited from |
Select Entities with the given IDs
The returned Entity[] array has Entity IDs as keys.
public function selectBatch(
Parameter #0 [ <required> array $ids ]
): array
NodeDao::deleteWhere
predicates |
public |
inherited from |
Delete Entity rows with a where-clause
DELETE FROM %table_name% WHERE %expression%
public function deleteWhere(
Parameter #0 [ <required> string $where_clause ]
): int
NodeDao::selectWhere
predicates |
public |
inherited from |
Select Entities with a where-clause
SELECT FROM %table_name% WHERE %expression% LIMIT %offset%, %limit%;
The optional $func receives selected Entities and can decide what key the Entity will have in the returned Entity[] array. Default: the returned Entity[] array has Entity IDs as keys.
$func = function(Entity $entity): int {
return $entity->getID();
};
public function selectWhere(
Parameter #0 [ <required> string $where_clause ]
Parameter #1 [ <optional> int $offset = 0 ]
Parameter #2 [ <optional> int $limit = bhenk\msdata\abc\PHP_INT_MAX ]
Parameter #3 [ <optional> ?Closure $func = NULL ]
): array
NodeDao::selectSql
predicates |
public |
inherited from |
Select Entities with a sql statement
The optional $func receives selected Entities and can decide what key the Entity will have in the returned Entity[] array. Default: the returned Entity[] array has Entity IDs as keys.
$func = function(Entity $entity): int {
return $entity->getID();
};
If the $sql selects not all fields from the designated table or selects from tables other than the designated, the result is unpredictable.
public function selectSql(
Parameter #0 [ <required> string $sql ]
Parameter #1 [ <optional> ?Closure $func = NULL ]
): array
NodeDao::execute
predicates |
public |
inherited from |
Execute the given query
public function execute(
Parameter #0 [ <required> string $sql ]
): array|bool
Sat, 01 Jul 2023 13:02:23 +0000