SQL query builder and database migration tool.
composer require furkifor/sql_dumper
$sql_dumper = new Furkifor\SqlDumper("users");
// Simple query
echo $sql_dumper->select('*')->get();
// SELECT * FROM users
// Query with conditions
echo $sql_dumper->select('name, email')
->where('age > ?', [18])
->orderBy('name', 'DESC')
->limit(10)
->get();
// SELECT name, email FROM users WHERE age > ? ORDER BY name DESC LIMIT 10
// JOIN operations
echo $sql_dumper->select('users.*, roles.name as role_name')
->join('INNER', 'roles', 'users.role_id = roles.id')
->where('users.active = ?', [1])
->get();
// SELECT users.*, roles.name as role_name FROM users
// INNER JOIN roles ON users.role_id = roles.id WHERE users.active = ?
// Grouping and HAVING
echo $sql_dumper->select('country, COUNT(*) as user_count')
->groupBy('country')
->having('user_count > 100')
->get();
// SELECT country, COUNT(*) as user_count FROM users
// GROUP BY country HAVING user_count > 100
$table = new MigrateClass("mysql");
// Simple table creation
$table->name("users")
->string('username', 255)->unique()->notnull()
->string('email', 255)->unique()->notnull()
->string('password', 255)->notnull()
->datetime('created_at')->default("CURRENT_TIMESTAMP")
->createTable();
// Table with relationships
$table->name("posts")
->string('title', 255)->notnull()
->text('content')
->int('user_id')->notnull()
->foreignKey('user_id', 'users', 'id')
->datetime('published_at')->nullable()
->boolean('is_published')->default(0)
->createTable();
// Table with custom constraints
$table->name("products")
->string('name', 100)->notnull()
->decimal('price', 10, 2)->notnull()
->int('stock')->notnull()->default(0)
->check('price > 0')
->check('stock >= 0')
->createTable();
- CREATE SELECT queries
- WHERE conditions
- JOIN operations (INNER, LEFT, RIGHT)
- ORDER BY sorting
- GROUP BY grouping
- HAVING filtering
- LIMIT clause
- Parameter binding support
- DISTINCT queries
- Multiple database system support (MySQL, MongoDB, SQL Server)
- Support for all common data types
- Automatic ID/Primary Key generation
- Foreign Key relationships
- Unique constraints
- NOT NULL constraints
- DEFAULT values
- CHECK constraints
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
The MIT License (MIT). Please see License File for more information.