Download the PHP package ayela-emmanuel/ayela-orm without Composer

On this page you can find all versions of the php package ayela-emmanuel/ayela-orm. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package ayela-orm

AyelaORM - PHP ORM Package

AyelaORM is a lightweight PHP Object-Relational Mapping (ORM) package designed to simplify database interactions using PHP's PDO extension. It provides an easy-to-use interface for managing database schemas and objects, dynamically handles table creation and updates, and supports relationships between models, reducing the need for manual schema management and complex SQL queries.

Table of Contents

  1. Installation
  2. Usage
    • Database Setup
    • Creating Models
    • Saving Data
    • Retrieving Data
    • Updating Data
    • Deleting Data
  3. Advanced Querying
    • Simple Conditions
    • Advanced Conditions
    • Relationships (Joins)
    • One-to-Many and Many-to-Many Relationships
  4. Schema Management
    • Automatic Schema Updates
    • Custom SQL Types
    • Ignoring Properties
  5. Data Types and Serialization
  6. Error Handling
  7. License

Installation

Install the package using Composer:

Ensure that the PDO extension is enabled for your PHP installation (MySQL is the default). Add the necessary namespace AyelaORM to your project.

Usage

Database Setup

Before using AyelaORM, you must set up the database connection:

Creating Models

To create a model that interacts with the database, extend the DatabaseObject class:

Notes:

Register your model on startup to ensure the schema is up to date:

Saving Data

To save a new object to the database:

After saving, the db_id property will be populated with the primary key value from the database.

Retrieving Data

You can retrieve records using several built-in methods.

Get All Records

Get a Record by ID

Get the First Record

Updating Data

Update a field of a record by ID:

Deleting Data

Delete a Single Record

Delete Multiple Records

Advanced Querying

AyelaORM provides advanced querying capabilities without the need to write raw SQL. The findWhere and firstWhere methods allow you to retrieve records based on conditions.

Simple Conditions

Provide an associative array where keys are field names and values are the values to match.

Retrieve the first matching record:

Advanced Conditions

Provide an array of condition arrays, each containing a field, operator, and value.

Supported operators: =, >, <, >=, <=, !=, <>, LIKE.

Relationships (Joins)

AyelaORM supports relationships between models using foreign keys.

Defining Relationships

Saving Data with Relationships

Retrieving Data with Relationships

One-to-Many and Many-to-Many Relationships

One-to-Many Example

In the Author class, add a method to retrieve related Book objects:

Many-to-Many Example

Create a join table model:

Schema Management

AyelaORM automatically manages database schema changes. Whenever you define or modify properties in your models, AyelaORM checks and updates the table structure accordingly.

Automatic Schema Updates

If you set frozen to false during the database setup, the schema will be checked and updated on each model instantiation. Tables will be created if they do not exist, and columns will be added or modified when changes are detected.

Custom SQL Types

You can specify custom SQL types for your model properties using the #[SQLType("...")] attribute.

Ignoring Properties

To exclude a property from the database schema, use the #[SQLIgnore] attribute.

Data Types and Serialization

AyelaORM handles various data types, including:

Example of Serializable Object

Error Handling

If an error occurs during database operations, it is stored in the $last_error property of the object.


Feel free to reach out or open an issue if you encounter any problems or have suggestions for improvements!


Note: This documentation covers the latest features and provides examples to help you get started with AyelaORM. The package is designed to simplify your database interactions and manage relationships efficiently, allowing you to focus on building your application.


All versions of ayela-orm with dependencies

PHP Build Version
Package Version
Requires php Version >=8.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package ayela-emmanuel/ayela-orm contains the following files

Loading the files please wait ....