Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 

README.md

DAW PHP ORM - Library - Active Record Pattern

Latest Stable Version License

DAW PHP ORM is a Open Source PHP library of simple ORM.

Execute SQL queries with a nice syntax!

Author

Package developed by: Développeur PHP Freelance Developpeur web Freelance

Some simple examples

You have to possibly add condition to the SQL query if some condition are === true:

<?php

$articles = Article::load()
    ->select('title', 'description', 'content')
    ->where('status', '=', 1)
    ->when(Input::hasGet('search'), function ($query) {
        return $query->where('title', 'LIKE', '%'.Input::get('search').'%');
    })
    ->findAll();

You have the possibility to paginate automatically:

<?php

$article = new Article();

$articles = $article->where('status', '=', 1)->paginate();

echo $article->getTotal();  // int - Number of articles paginated

// Show articles
foreach ($articles as $item) {
    echo $item->title;
}

// Show the Pagination
echo $article->getPagination()->render();
echo $article->getPagination()->perPage();

You have the possibility to use Active Record Pattern:

<?php

$article = new Article();
$article->setTitle('Title');
$article->setDescription('Description');
$article->setContent('Content');
$article->setSlug('article-slug');
$article->save();

You have the possibility to retrieve an element, or to return a 404 error if it does not exist:

<?php

$article = Article::load()->findOrFail($id);

You also have many other features.

Requirements

  • PHP >= 7.1

If you want an accounting with PHP 7.0, you can use version 1.1: DAW PHP ORM 1.1

Dependencies

Documentation

  • The documentation is in folder "docs" of this package:

English | French

Installation

Installation via Composer:

php composer.phar require stephweb/daw-php-orm 2.0.*

Contributing

Bugs and security Vulnerabilities

If you discover a bug or a security vulnerability within DAW PHP ORM, please send a message to Stephen. Thank you. All bugs and all security vulnerabilities will be promptly addressed.

License

The DAW PHP ORM is Open Source software licensed under the MIT license.

You can’t perform that action at this time.