{"id":25363472,"url":"https://github.com/vitexsoftware/php-ease-fluentpdo","last_synced_at":"2025-10-30T01:31:52.694Z","repository":{"id":55468114,"uuid":"200287878","full_name":"VitexSoftware/php-ease-fluentpdo","owner":"VitexSoftware","description":"Database support for EasePHP Framework","archived":false,"fork":false,"pushed_at":"2025-01-08T12:44:40.000Z","size":432,"stargazers_count":5,"open_issues_count":3,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-01-27T21:24:11.101Z","etag":null,"topics":["database","easephp-framework","fluentpdo","php"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/VitexSoftware.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":null,"patreon":"VitexSoftware","open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2019-08-02T19:30:39.000Z","updated_at":"2025-01-08T12:32:11.000Z","dependencies_parsed_at":"2023-10-01T23:33:11.135Z","dependency_job_id":"1582e9ba-a00a-4205-8f1c-b3182675fb83","html_url":"https://github.com/VitexSoftware/php-ease-fluentpdo","commit_stats":{"total_commits":139,"total_committers":4,"mean_commits":34.75,"dds":0.02877697841726623,"last_synced_commit":"8fee5b3aa63c45e2d0b66f42a7d38b6aa88be6cb"},"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VitexSoftware%2Fphp-ease-fluentpdo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VitexSoftware%2Fphp-ease-fluentpdo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VitexSoftware%2Fphp-ease-fluentpdo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VitexSoftware%2Fphp-ease-fluentpdo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/VitexSoftware","download_url":"https://codeload.github.com/VitexSoftware/php-ease-fluentpdo/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238920812,"owners_count":19552673,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["database","easephp-framework","fluentpdo","php"],"created_at":"2025-02-14T22:32:50.565Z","updated_at":"2025-10-30T01:31:52.688Z","avatar_url":"https://github.com/VitexSoftware.png","language":"PHP","readme":"# EaseSQL - FluentPDO Integration\n\nSQL/PDO Support for EasePHP Framework using FluentPDO\n\n![Project logo](php-ease-fluentpdo.svg?raw=true)\n\n[![Latest Stable Version](https://poser.pugx.org/vitexsoftware/ease-fluentpdo/version)](https://packagist.org/packages/vitexsoftware/ease-fluentpdo)\n[![Total Downloads](https://poser.pugx.org/vitexsoftware/ease-fluentpdo/downloads)](https://packagist.org/packages/vitexsoftware/ease-fluentpdo)\n[![Latest Unstable Version](https://poser.pugx.org/vitexsoftware/ease-fluentpdo/v/unstable)](//packagist.org/packages/vitexsoftware/ease-fluentpdo)\n[![License](https://poser.pugx.org/vitexsoftware/ease-fluentpdo/license)](https://packagist.org/packages/vitexsoftware/ease-fluentpdo)\n[![Monthly Downloads](https://poser.pugx.org/vitexsoftware/ease-fluentpdo/d/monthly)](https://packagist.org/packages/vitexsoftware/ease-fluentpdo)\n[![Daily Downloads](https://poser.pugx.org/vitexsoftware/ease-fluentpdo/d/daily)](https://packagist.org/packages/vitexsoftware/ease-fluentpdo)\n\n## Overview\n\nThis library provides SQL database support for the [EasePHP Framework](https://github.com/VitexSoftware/php-ease-core) using [FluentPDO](https://github.com/fpdo/fluentpdo) for fluent SQL query building. It bridges the gap between Ease Framework's object-oriented approach and modern database operations.\n\n### Features\n\n- **Multi-database Support**: MySQL, PostgreSQL, SQLite, SQL Server\n- **Fluent Query Builder**: Intuitive SQL query construction\n- **ORM Capabilities**: Object-relational mapping with the Ease Framework\n- **Connection Management**: Persistent and non-persistent connections\n- **Debug Support**: SQL query logging and debugging\n- **Migration Support**: Database schema versioning with Phinx\n- **Logging Integration**: Built-in SQL logging capabilities\n\n### Key Components\n\n- `\\Ease\\SQL\\Engine` - Main database engine with FluentPDO integration\n- `\\Ease\\SQL\\PDO` - Enhanced PDO wrapper\n- `\\Ease\\SQL\\Orm` - Object-relational mapping base class\n- `\\Ease\\SQL\\SQL` - Abstract SQL operations class\n- `\\Ease\\Logger\\LogToSQL` - Database logging functionality\n\n\n## Quick Start\n\n```php\n\u003c?php\nrequire_once 'vendor/autoload.php';\n\n// Configure database connection\ndefine('DB_TYPE', 'mysql');\ndefine('DB_HOST', 'localhost');\ndefine('DB_DATABASE', 'myapp');\ndefine('DB_USERNAME', 'user');\ndefine('DB_PASSWORD', 'password');\n\n// Create a database-backed object\nclass User extends \\Ease\\SQL\\Engine {\n    public function __construct($identifier = null) {\n        $this-\u003emyTable = 'users';\n        $this-\u003ekeyColumn = 'id';\n        parent::__construct($identifier);\n    }\n}\n\n// Usage example\n$user = new User();\n$user-\u003esetDataValue('name', 'John Doe');\n$user-\u003esetDataValue('email', 'john@example.com');\n$user-\u003esave(); // Inserts or updates the record\n```\n\n## Installation\n\nDownload https://github.com/VitexSoftware/php-ease-fluentpdo/archive/master.zip or use\n\nComposer\n--------\n\n```shell\n    composer require vitexsoftware/ease-fluentpdo\n```\n\nLinux\n-----\n\nFor Debian, Ubuntu \u0026 friends please use repo:\n\n```shell\necho \"deb http://repo.vitexsoftware.com $(lsb_release -sc) main\" | sudo tee /etc/apt/sources.list.d/vitexsoftware.list\nsudo wget -O /etc/apt/trusted.gpg.d/vitexsoftware.gpg http://repo.vitexsoftware.com/keyring.gpg\nsudo apt update\nsudo apt install php-vitexsoftware-ease-fluentpdo\n```\n\nIn this case please add this to your app composer.json:\n\n```json\n    \"require\": {\n        \"deb/ease-fluentpdo\": \"*\"\n    },\n    \"repositories\": [\n        {\n            \"type\": \"path\",\n            \"url\": \"/usr/share/php/EaseSQL\",\n            \"options\": {\n                \"symlink\": true\n            }\n        }\n    ]\n```\n\n## Configuration\n\n### Environment Constants\n\nThe library uses these environment constants for database configuration:\n\n| Constant | Description | Default | Example |\n|----------|-------------|---------|----------|\n| `DB_TYPE` | Database type | - | `mysql`, `pgsql`, `sqlite`, `sqlsrv` |\n| `DB_HOST` | Database host | `localhost` | `127.0.0.1`, `db.example.com` |\n| `DB_PORT` | Database port | - | `3306`, `5432` |\n| `DB_DATABASE` | Database name/schema | - | `myapp`, `production_db` |\n| `DB_USERNAME` | Database user | - | `dbuser`, `app_user` |\n| `DB_PASSWORD` | Database password | - | `secret123` |\n| `DB_SETUP` | Setup commands after connect | - | `SET NAMES utf8` |\n| `DB_PERSISTENT` | Use persistent connections | `1` | `0` (disable), `1` (enable) |\n| `DB_SETTINGS` | PDO connection settings | - | JSON string of PDO options |\n| `DB_DEBUG` | Enable SQL query logging | `false` | `true`, `false` |\n\n### Configuration Examples\n\n#### MySQL Configuration\n```php\ndefine('DB_TYPE', 'mysql');\ndefine('DB_HOST', 'localhost');\ndefine('DB_PORT', '3306');\ndefine('DB_DATABASE', 'myapp');\ndefine('DB_USERNAME', 'dbuser');\ndefine('DB_PASSWORD', 'password');\ndefine('DB_SETUP', 'SET NAMES utf8mb4');\n```\n\n#### PostgreSQL Configuration\n```php\ndefine('DB_TYPE', 'pgsql');\ndefine('DB_HOST', 'localhost');\ndefine('DB_PORT', '5432');\ndefine('DB_DATABASE', 'myapp');\ndefine('DB_USERNAME', 'postgres');\ndefine('DB_PASSWORD', 'password');\n```\n\n#### SQLite Configuration\n```php\ndefine('DB_TYPE', 'sqlite');\ndefine('DB_DATABASE', '/path/to/database.sqlite');\n```\n\n## Usage Examples\n\n### Basic ORM Operations\n\n```php\n// Create a model class\nclass Article extends \\Ease\\SQL\\Engine {\n    public function __construct($identifier = null) {\n        $this-\u003emyTable = 'articles';\n        $this-\u003ekeyColumn = 'id';\n        parent::__construct($identifier);\n    }\n}\n\n// Create new record\n$article = new Article();\n$article-\u003esetDataValue('title', 'My First Article');\n$article-\u003esetDataValue('content', 'This is the content...');\n$article-\u003esetDataValue('author_id', 1);\n$savedId = $article-\u003esave();\n\n// Load existing record\n$article = new Article(1);\necho $article-\u003egetDataValue('title');\n\n// Update record\n$article-\u003esetDataValue('title', 'Updated Title');\n$article-\u003esave();\n\n// Delete record\n$article-\u003edelete();\n```\n\n### FluentPDO Query Builder\n\n```php\n$engine = new \\Ease\\SQL\\Engine();\n\n// Select with conditions\n$users = $engine-\u003elistingQuery()\n    -\u003efrom('users')\n    -\u003ewhere('active = ?', 1)\n    -\u003ewhere('created_at \u003e ?', '2023-01-01')\n    -\u003eorderBy('name ASC')\n    -\u003efetchAll();\n\n// Complex joins\n$articles = $engine-\u003elistingQuery()\n    -\u003efrom('articles a')\n    -\u003eleftJoin('users u ON a.author_id = u.id')\n    -\u003eselect('a.*, u.name as author_name')\n    -\u003ewhere('a.published = ?', 1)\n    -\u003efetchAll();\n```\n\n### Logging to Database\n\n```php\n// Configure SQL logging\ndefine('DB_DEBUG', true);\n\n// Log messages to database\n$logger = new \\Ease\\Logger\\LogToSQL();\n$logger-\u003eaddToLog('Application started', 'info');\n$logger-\u003eaddToLog('User login failed', 'warning', ['user_id' =\u003e 123]);\n```\n\n## Development \u0026 Testing\n\n### Prerequisites\n\n- PHP 7.4 or higher\n- Composer\n- Database server (MySQL, PostgreSQL, SQLite, or SQL Server)\n\n### Setup Development Environment\n\n```bash\n# Clone repository\ngit clone https://github.com/VitexSoftware/php-ease-fluentpdo.git\ncd php-vitexsoftware-ease-fluentpdo\n\n# Install dependencies\ncomposer install\n\n# Copy environment configuration\ncp tests/.env.example tests/.env\n# Edit tests/.env with your database credentials\n```\n\n### Database Setup for Testing\n\n#### MySQL\n```bash\nmysqladmin -u root -p create easetest\nmysql -u root -p -e \"GRANT ALL PRIVILEGES ON easetest.* TO easetest@localhost IDENTIFIED BY 'easetest'\"\n```\n\n#### PostgreSQL\n```bash\nsudo -u postgres createuser --createdb --password easetest\nsudo -u postgres createdb -O easetest easetest\n```\n\n#### Run Migrations\n```bash\ncd tests\n../vendor/bin/phinx migrate\n../vendor/bin/phinx seed:run\n```\n\n### Running Tests\n\n```bash\n# Run all tests\nmake phpunit\n\n# Or run directly with PHPUnit\n./vendor/bin/phpunit --bootstrap ./tests/bootstrap.php --configuration ./phpunit.xml\n\n# Run specific test\n./vendor/bin/phpunit tests/src/Ease/SQL/EngineTest.php\n```\n\n### Code Quality\n\n```bash\n# Static analysis\nmake static-code-analysis\n\n# Code style fixes\nmake cs\n\n# Run all quality checks\ncomposer test\n```\n\n## Building \u0026 Packaging\n\n### Debian Package\n\n```bash\n# Build Debian package\nmake deb\n# or\ndpkg-buildpackage -b -uc\n```\n\n### Composer Package\n\n```bash\n# Validate composer.json\ncomposer validate\n\n# Update dependencies\ncomposer update\n\n# Create optimized autoloader\ncomposer dump-autoload --optimize\n```\n\n## API Reference\n\n### Core Classes\n\n#### `\\Ease\\SQL\\Engine`\nMain database engine class providing ORM functionality.\n\n**Key Methods:**\n- `save()` - Insert or update record\n- `load($id)` - Load record by ID\n- `delete()` - Delete current record\n- `listingQuery()` - Get FluentPDO query builder\n- `setDataValue($key, $value)` - Set field value\n- `getDataValue($key)` - Get field value\n\n#### `\\Ease\\SQL\\PDO`\nEnhanced PDO wrapper with additional functionality.\n\n#### `\\Ease\\SQL\\Orm`\nBase ORM class for database-backed objects.\n\n#### `\\Ease\\Logger\\LogToSQL`\nDatabase logging implementation.\n\n**Methods:**\n- `addToLog($message, $type, $data)` - Add log entry\n- `getLogLevel()` - Get current log level\n- `setLogLevel($level)` - Set log level\n\n## Migration Support\n\nThe library includes support for database migrations using Phinx:\n\n```bash\n# Create new migration\nmake newmigration\n\n# Run migrations\nmake migration\n\n# Create seed\nmake newseed\n\n# Run seeds\nmake seed\n```\n\n## Contributing\n\n1. Fork the repository\n2. Create your feature branch (`git checkout -b feature/amazing-feature`)\n3. Make your changes\n4. Run tests (`make phpunit`)\n5. Run code quality checks (`make cs \u0026\u0026 make static-code-analysis`)\n6. Commit your changes (`git commit -m 'Add amazing feature'`)\n7. Push to the branch (`git push origin feature/amazing-feature`)\n8. Open a Pull Request\n\n## Requirements\n\n- **PHP**: \u003e= 7.4\n- **Extensions**: PDO with appropriate database drivers\n- **Dependencies**:\n  - `vitexsoftware/ease-core`: \u003e= 1.49.0\n  - `fpdo/fluentpdo`: \u003e= 2.2.4\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n## Links \u0026 Resources\n\n- **Homepage**: https://www.vitexsoftware.cz/ease.php\n- **GitHub**: https://github.com/VitexSoftware/php-ease-fluentpdo\n- **Packagist**: https://packagist.org/packages/vitexsoftware/ease-fluentpdo\n- **Documentation**: https://github.com/VitexSoftware/php-ease-fluentpdo/wiki\n- **Issue Tracker**: https://github.com/VitexSoftware/php-ease-fluentpdo/issues\n- **EasePHP Core**: https://github.com/VitexSoftware/php-ease-core\n- **FluentPDO**: https://github.com/fpdo/fluentpdo\n\n## Support\n\nFor support and questions:\n- Create an [issue](https://github.com/VitexSoftware/php-ease-fluentpdo/issues)\n- Contact: info@vitexsoftware.cz\n- Visit: https://www.vitexsoftware.cz\n","funding_links":["https://patreon.com/VitexSoftware"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvitexsoftware%2Fphp-ease-fluentpdo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvitexsoftware%2Fphp-ease-fluentpdo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvitexsoftware%2Fphp-ease-fluentpdo/lists"}