Skip to content
Open
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
test_mysql_connection_credentials.php
.idea
45 changes: 41 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
# Autodb

BREAKING NEWS: As of PHP 8.1 pg_connect returns a diffferent object, so:
<h3>This is a modified version of the original dszakal/autodb</h3>
<h3>The minimum PHP version supported is PHP 8.1</h3>

LATEST SUPPORTED VERSION: PHP 8.0.x

CURRENT RELEASE NOT WORKING WITH: PHP 8.1.0 or later
LATEST SUPPORTED VERSION: PHP 8.3.

CURRENT RELEASE NOT WORKING WITH: PHP 7.4 or previous

A very simple automated single table read-write Active Record Pattern implementation.

Old Stable: 000.030
Old Stable: 000.030 (for previous PHP versions)

PostgreSQL support (php-pgsql (pg_connect, resource), NOT php-pdo-pgsql) from: 000.042

Composite Primary Key from: 1.0.0.3

LIMITATIONS TO BE AWARE OF BEFORE YOU WOULD USE:

This is not ORM. Just an active record pattern, it doesn't support joins on purpose.
Expand All @@ -32,6 +36,35 @@ LIMITATIONS TO BE AWARE OF BEFORE YOU WOULD USE:
PDO is not supported, and is not planned to be supported
For now, type checking is very basic, will improve


COMPOSITE PRIMARY KEY:

Usage:
```php
//In your autodb project, define the constant AUTODB_ALLOW_PG_COMPOSITE_PK:
define('AUTODB_ALLOW_PG_COMPOSITE_PK', true);
```
Limitations:

**Purpose**
The constant AUTODB_ALLOW_PG_COMPOSITE_PK in autodb controls whether the library allows the use of composite primary keys in the context of database operations it manages.

**Functionality**
Library Configuration:
When AUTODB_ALLOW_PG_COMPOSITE_PK is set to true, autodb permits the use of composite primary keys.
If it is not defined (default behaviour) or set to false, composite primary keys are not allowed.

Conditions for Composite PK:
- autodb imposes specific conditions for composite primary keys:
- The primary key must include id_table_name as a serial (auto-incrementing integer) column.
- id_table_name must be the only int type column in the composite primary key.
- Any deviation from these conditions will result in an exception thrown by autodb.

Exception Handling:
If the conditions for composite primary keys are not met, autodb will throw an exception. This ensures that the usage aligns with the expected behavior and maintains integrity in database operations managed by autodb.



Usage example:

```php
Expand Down Expand Up @@ -161,3 +194,7 @@ CONCURRENT WRITE SUPPORT
define('PGSQL_CONN_STRING', 'host=localhost port=5432 user=myuser password=mypassword'); // do not worry about conn db

```




6 changes: 5 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
{
"name": "dszakal/autodb",
"name": "salvosav/autodb",
"description": "AutoDB package",
"license": "BSD",
"keywords": ["autodb"],
"authors": [
{
"name": "Daniel Szakal",
"email": "dszakal89@icloud.com"
},
{
"name": "Salvatore Campanella",
"email": "salvo.sav@gmail.com"
}
],
"require": {
Expand Down
Loading