- NOTE: This is a "work in progress" document and will take a few weeks to be fully filled out. Most things listed in this document will become full pages of their own and linked here in the very near future.
PUDL Documentation
What is PUDL
PUDL stands for "PHP Universal Database Library" and can simply be described as "PDO on crack." PUDL provides a straightforward, simple, and standardized API for connecting to various database engines using the available PHP extensions transparently. Additionally, PUDL provides APIs for automatically generating SQL queries as well as processing the resulting data.
The subtle nuances of each database's SQL implementation are handled automatically behind the scenes by PUDL.
Getting Started
Supported Database Engines and PHP Extensions
Class |
Support |
Information |
pudl |
Full |
The core shared API |
pudlNull |
Full |
Think /dev/null, no connection made, calls return default value |
pudlMySql |
Full |
Legacy MySQL (deprecated in PHP 5.5.0, removed in PHP 7.0.0) |
pudlMySqli |
Full |
Modern MySQL, MariaDB, and Percona |
pudlGalera |
Full |
MySqli interface extended with Galera multi-master clustering |
pudlMsSql |
Partial |
Legacy Microsoft SQL Server (removed in PHP 7.0.0) |
pudlSqlSrv |
Partial |
Modern Microsoft SQL Server |
pudlPgSql |
Partial |
PostgreSQL |
pudlSqlite |
Partial |
Local Sqlite3 file |
pudlOdbc |
Partial |
Open Database Connectivity |
pudlPdo |
Partial |
PHP's built in PDO |
pudlClone |
Early |
A cloned interface linking to another PUDL instance |
pudlShell |
Early |
JSON API accessed via piped connections on a local shell |
pudlWeb |
Early |
JSON API accessed via HTTP(s) |
Basic Queries
API Documentation
Classes
Constants
Prefix |
Information |
PUDL_ |
Main PUDL constants |
GALERA_ |
Galera cluster status |
Interfaces
Interface |
Information |
pudlData |
Used internally to identify specific data structures |
pudlHelper |
Used internally to identify special PUDL related classes |
pudlId |
Allows an object to be passed into an Id() function as a value |
pudlValue |
Used internally to identify special PUDL values |
Object-Relational Mapping (ORM)
Class |
Information |
pudlObject |
A basic object that acts like a PHP Array |
pudlOrm |
A hybrid between pudlObject and the main PUDL interface |
pudlCollection |
A collection of pudlOrm objects |
Importing / Exporting
- pudlImport
- pudlImportCsv
- pudlImportExcel
- pudlExportExcel
PUDL Methods
SQL DML (Data Manipulation Language)
SELECT
- select
- having
- group
- groupHaving
- orderGroup
- orderGroupEx
- distinct
- distinctGroup
- selectExplain
- selex
- selectRow
- row
- rowEx
- selectRows
- rows
- rowId
- rowsId
- cell
- cellId
- id
- collection
- estimate
- total
- count
- countId
- countGroup
INSERT / UPSERT / REPLACE
- insert
- upsert
- exsert
- insertId
- insertValues
- insertExtract
- upsertExtract
- insertUpdate
- insertEx
- insertInto
- replace
- replaceEx
- replaceInto
UPDATE
- updated
- update
- updateIn
- updateId
- updateExtract
- updateExtractIn
- updateExtractId
- updateField
- updateFieldId
- updateCount
- increase
- incrementId
DELETE
- delete
- deleteId
- deleteRow
SQL TCL (Transaction Control Language)
- inTransaction
- retryTransaction
- lock
- unlock
BEGIN / START TRANSACTION
SAVEPOINT
COMMIT TRANSACTION
ROLLBACK TRANSACTION
SQL DDL (Data Definition Language)
- tables
- tableExists
- tableStatus
CREATE
ALTER
- alter (not available yet)
- addVersioning
DROP
TRUNCATE
RENAME
SQL DCL (Data Control Language)
GRANT
REVOKE