Releases: Planetbiru/MagicObject
3.0.0
MagicObject Version 3.0
What's New
-
SQL Server Database Support
This feature expands user options by providing support for SQL Server, offering more flexibility in choosing DBMS. -
Time Zone Conversion for SQLite and SQL Server Databases
This feature automatically converts time in databases that do not natively support time zone conversion, such as SQLite and SQL Server. -
Database Time Zone Change After Object Construction
Users can now change the database's time zone at any time as needed. This provides greater flexibility when handling data across multiple time zones, especially when the application is used by users from different time zones, all without the need to modify the application configuration. -
Yaml Parser and Dumper
MagicObject version 3.0 no longer depends on external libraries. The Yaml parsing and dumping functions are now fully handled by a class that is part of MagicObject itself, reducing its overall complexity. -
Added
BETWEENFilter for Predicate Queries
MagicObject now supportsBETWEENfilters for predicate-based queries, allowing users to perform range-based filtering efficiently. This improves query performance and simplifies conditions when working with numerical or date ranges.
Full Changelog: 2.16.0...3.0.0
2.16.0
What's Changed
- Feature/2.11 by @kamshory in #45
- Feature/2.11 by @kamshory in #46
- Feature/2.12 by @kamshory in #47
- Update PicoDatabase by @kamshory in #48
- Feature/2.14.1 by @kamshory in #49
- Feature/2.14.1 by @kamshory in #50
- Feature/2.14.1 by @kamshory in #51
- Feature/2.15 by @kamshory in #52
- Feature/2.15 by @kamshory in #53
- Delete doc.html by @kamshory in #54
- Update js.js by @kamshory in #55
- Feature/2.15 by @kamshory in #56
- Update MagicObject.php by @kamshory in #57
Full Changelog: 2.15.7...2.16.0
2.15.0
Full Changelog: 2.14.16...2.15.0
2.14.0
Full Changelog: 2.13.2...2.14.0
2.13.0
Full Changelog: 2.11.7...2.13.0
2.11.0
MagicObject Version 2.11
What's New
-
Dynamic Query Template for Native Queries
MagicObject now supports dynamic query templates for native SQL queries. This feature allows developers to build SQL queries dynamically, providing flexibility and improving code reusability. The dynamic query template can be customized to suit specific use cases, making it easier to construct complex queries while maintaining cleaner and more maintainable code. -
Added
DROP TABLE IF EXISTSandCREATE TABLE IF NOT EXISTSto SQL Code Generation
MagicObject now generates SQL code withDROP TABLE IF EXISTSandCREATE TABLE IF NOT EXISTSstatements when creating tables from entities. This ensures that the table creation process is more robust, preventing errors when a table already exists. -
Standardization of Annotation Attribute Naming with Camel Case Strategy
The annotation attributes in MagicObject have been standardized to follow the camel case naming convention, ensuring consistency and better readability throughout the codebase. -
Refactoring of Methods with Constant Usage
To prevent duplication and errors in the code, several methods have been refactored to utilize constants. This improves maintainability and reduces the chances of mistakes during development. -
Option to Prettify Serialize for
SecretObject
A new option has been added to allowSecretObjectto be serialized with pretty formatting. This makes it easier to read and inspect serializedSecretObjectdata, especially useful during development or debugging. Theprettifyflag can be enabled when serializing the object, ensuring the output is more human-readable with proper indentation. -
Updated Documentation
The documentation has been updated to reflect the latest changes in MagicObject. This includes clarifications, examples, and explanations to assist developers in understanding and utilizing the library effectively.
Full Changelog: 2.10.3...2.11.0
2.10.0
Full Changelog: 2.9.10...2.10.0
2.9.0
Version 2.9
What is New
- Add database charset
- Fixing PostgreSQL connection
- Fixing PostgreSQL script generation
- Fixing SQLite script generation
- Fixing database time zone connection
- Fixing database namespace for PostgreSQL connection
Full Changelog: 2.8.5...2.9.0
2.8.0
2.7.0
MagicObject Version 2.7
What's New
MagicObject 2.7 brings a set of powerful updates to improve database interaction, query flexibility, and transaction management. The main highlights of this release include support for PDO connections, enhanced native query capabilities with pagination and sorting, and new transactional methods for improved data management.
1. PDO Support
One of the most significant changes in MagicObject 2.7 is the introduction of support for PDO (PHP Data Objects). In previous versions, MagicObject required the use of its custom database handler, PicoDatabase. However, to accommodate developers who prefer working with PDO connections, this new version allows users to pass a PDO connection directly to the MagicObject constructor.
Why PDO Support?
The decision to include PDO support was driven by the need to make MagicObject more versatile for developers who are already using PDO in their applications. By allowing PDO connections, MagicObject now supports a broader range of use cases and provides users with the flexibility to integrate with existing PDO-based database connections.
While PDO is supported for the initial connection setup, MagicObject continues to use PicoDatabase for all subsequent database operations. This ensures that users still benefit from PicoDatabase's advanced features, such as automatic query building, database abstraction, and optimized query execution.
How PDO Support Works
In MagicObject 2.7, when you pass a PDO connection object to the constructor, it is internally converted into a PicoDatabase instance via the PicoDatabase::fromPdo() static method. This ensures that although PDO is used for establishing the initial connection, PicoDatabase manages the actual database interactions. Additionally, MagicObject automatically detects the database type based on the PDO driver to ensure smooth operation.
2. Pageable and Sortable in Native Queries
Another important enhancement in MagicObject 2.7 is the introduction of pageable and sortable support in native queries. Prior to this release, native queries lacked direct support for pagination and sorting. Developers had to manually include ORDER BY and LIMIT OFFSET clauses in their queries, leading to more cumbersome code that was difficult to maintain and adapt across different database platforms.
With MagicObject 2.7, you can now pass pagination parameters using the PicoPageable type and sorting parameters using the PicoSortable type directly into your native queries. These parameters can be placed at any point in the query, though it's recommended to position them either at the beginning or end for optimal readability and organization.
This improvement enhances the flexibility of native queries, as the logic for pagination and sorting is handled automatically, reducing the need for manual intervention. By supporting these features, MagicObject 2.7 allows you to write cleaner, more efficient, and database-agnostic queries. You can now easily handle pagination and sorting logic regardless of the underlying database system.
3. Transaction Management
MagicObject 2.7 introduces enhanced support for transactional database operations, including three new methods: startTransaction(), commit(), and rollback(). These methods provide an easy and efficient way to manage database transactions within MagicObject.
- startTransaction(): Begins a new database transaction.
- commit(): Commits the current transaction, saving all changes made during the transaction to the database.
- rollback(): Rolls back the current transaction, undoing any changes made since the transaction began.
These methods are designed to work seamlessly with an active database connection, allowing developers to handle transactions directly within the context of their application. Whether you're managing financial transactions or ensuring data consistency during batch processing, these functions streamline the management of transaction-based operations.
Full Changelog: 2.6.1...2.7.0