Setup & Connection
Initialize the engine and connect to your encrypted file.
$db->connect(file, password)
db.connect(file, password)
Loads an existing .asdf file into memory securely.
require_once 'GLOBAL.asdf';
$db = new asdf();
$db->connect('Users.asdf', 'my_secure_key');
echo "Connected successfully!";
from GLOBAL_ASDF import ASDFPy
db = ASDFPy()
db.connect('TableName.asdf', 'Password')
print("Connected successfully!")
Create Table
Define a new database schema programmatically.
$db->create(name, pass, cols)
db.create(name, pass, cols)
$db->create('TableName', 'Password', [
'username' => 'text',
'email' => 'email',
'is_active'=> 'boolean'
]);
db.create('TableName', 'Password', {
'username': 'text',
'email': 'email',
'is_active': 'boolean'
})
Insert Data
Add new rows. The ID column is auto-incremented automatically.
$db->insertRow(array)
db.insert_row(dict)
$newId = $db->insertRow([
'username' => 'john_doe',
'email' => 'john@example.com',
'is_active'=> true
]);
new_id = db.insert_row({
'username': 'john_doe',
'email': 'john@example.com',
'is_active': True
})
Fetch Data
Retrieve data from the system. ASDL supports both raw data and HTML rendering.
$db->find(conditions)
db.find(conditions)
Get an array of rows matching criteria.
// Find all active users
$users = $db->find(['is_active' => '1']);
# Find all active users
users = db.find({'is_active': '1'})
$db->findOneFast(column, value)
db.find_one_fast(column, value)
Uses Hash Map Indexing for O(1) speed. Requires
addIndex().$user = $db->findOneFast('email', 'john@example.com');
user = db.find_one_fast('email', 'john@example.com')
$db->getHTMLTable()
db.get_html_table()
Auto-generates a responsive HTML table.
echo $db->getHTMLTable();
print(db.get_html_table())
Update Data
Modify existing records using conditions or direct cell targeting.
$db->update(conds, updates)
db.update(conds, updates)
$count = $db->update(
['name' => 'John'], // Condition
['is_active' => '1'] // New Value
);
count = db.update(
{'name': 'John'}, # Condition
{'is_active': '1'} # New Value
)
Delete & Drop
Remove rows or destroy tables entirely.
$db->delete(conditions)
db.delete(conditions)
$deleted = $db->delete(['is_active' => '0']);
deleted = db.delete({'is_active': '0'})
Schema Management
$db->insertColumn(name, type)
db.insert_column(name, type)
$db->insertColumn('phone', 'text', 'N/A');db.insert_column('phone', 'text', 'N/A')Insert File Data
$db->upload(inputName)
db.upload(filePath)
// PHP: Processes $_FILES
$photo = $db->upload('user_photo');
# Python: Reads local file path
photo = db.upload('/tmp/image.png')
Import / Export
$db->exportJSON()
db.export_json()
$json = $db->exportJSON(false);json_str = db.export_json(False)Smart Indexing
$db->addIndex(column)
db.add_index(column)
$db->addIndex('email');db.add_index('email')Relational Joins
$db->join(db2, col1, col2)
db.join(db2, col1, col2)
$data = $users->join($orders, 'id', 'user_id');data = users.join(orders, 'id', 'user_id')ACID Transactions
Transaction Workflow
try {
$db->beginTransaction();
$db->insertRow(['item' => 'A']);
$db->commit();
} catch (Exception $e) {
$db->rollback();
}
try:
db.begin_transaction()
db.insert_row({'item': 'A'})
db.commit()
except:
db.rollback()
Utilities
$db->exists(col, val)
db.exists(col, val)
if ($db->exists('id', 5)) { ... }if db.exists('id', 5): pass