All Projects → arojunior → php-orm-pdo

arojunior / php-orm-pdo

Licence: MIT license
Micro PHP ORM Library

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to php-orm-pdo

node-express-mongodb-reactjs-graphql
Node, Express, React.js, Graphql and MongoDB CRUD Web Application
Stars: ✭ 36 (+100%)
Mutual labels:  crud
spectre-canjs
A data administration component library built on the Spectre.css framework enabled with CanJS
Stars: ✭ 25 (+38.89%)
Mutual labels:  crud
varbox
THE Laravel Admin Panel package built by developers, for developers
Stars: ✭ 61 (+238.89%)
Mutual labels:  crud
cookbook
VueJS + NodeJS Evergreen Cookbook
Stars: ✭ 440 (+2344.44%)
Mutual labels:  crud
crudcast
Create and deploy a RESTful API with a few lines of YAML
Stars: ✭ 32 (+77.78%)
Mutual labels:  crud
api
_api is an autogenerated CRUD API built on LowDB and ExpressJS.
Stars: ✭ 73 (+305.56%)
Mutual labels:  crud
ionic4-angular7-example
Ionic 4, Angular 7 and Cordova Tutorial: Build CRUD Mobile Apps
Stars: ✭ 57 (+216.67%)
Mutual labels:  crud
laravel-backpack-crud-extended
This package extends Backpack/CRUD, to add some awesome features!
Stars: ✭ 60 (+233.33%)
Mutual labels:  crud
mern-stack-crud
MERN stack (MongoDB, Express, React and Node.js) create read update and delete (CRUD) web application example
Stars: ✭ 142 (+688.89%)
Mutual labels:  crud
react-with-nodejs-and-sequelize
React-Redux application using NodeJS relational database API with Sequelize ORM. Two level CRUD with a main data table (bands) and other that is relationed with it (albums).
Stars: ✭ 30 (+66.67%)
Mutual labels:  crud
therack
Laravel 7 e-commerce website
Stars: ✭ 77 (+327.78%)
Mutual labels:  crud
vue-js-3-firebase-firestore
Vue 3 Firebase Tutorial: Build Firestore CRUD Web Application
Stars: ✭ 34 (+88.89%)
Mutual labels:  crud
remult
A CRUD framework for full stack TypeScript
Stars: ✭ 1,488 (+8166.67%)
Mutual labels:  crud
Processor
Ontology-driven Linked Data processor and server for SPARQL backends. Apache License.
Stars: ✭ 54 (+200%)
Mutual labels:  crud
ohcrud
OhCRUD PHP framework. http://ohcrud.erfan.me/
Stars: ✭ 25 (+38.89%)
Mutual labels:  crud
laravel-crudable
Laravel CRUD builder with ease
Stars: ✭ 40 (+122.22%)
Mutual labels:  crud
logrocket deno api
A functional CRUD-like API with Deno and Postgres
Stars: ✭ 23 (+27.78%)
Mutual labels:  crud
lara-crud
This package will give an opportunity to get a very flexible admin panel that will satisfy you most of the time.
Stars: ✭ 33 (+83.33%)
Mutual labels:  crud
CRUD.ASPCore.Reactjs.WebAPI.EF
CRUD Operations in ASP.NET Core application using React.js , Web API and Entity Framework core DB first approach with the help of VS 2017.
Stars: ✭ 80 (+344.44%)
Mutual labels:  crud
aarbac
An Automated Role Based Access Control .NET framework with T-SQL Query Parser which automatically parse select, insert, update, delete queries based on the logged in user role
Stars: ✭ 18 (+0%)
Mutual labels:  crud

Installing via composer and using as a lib

composer require arojunior/php-orm-pdo

create a file to overwrite the database config

use SimpleORM\core\model\Model;

class AppModel extends Model
{
    public $db_config = [
        'db_host' => '192.168.1.1',
        'db_name' => 'test',
        'db_user' => 'root',
        'db_pass' => ''
    ];
}

And then you can extend this class in your classes

use YourNamespace\AppModel;

class Example extends AppModel
{
    public $table = 't_user';
    public $pk    = 'user_id';

    public function getAll()
    {
        return $this->findAll();
    }
}

CRUD

namespace SimpleORM\app\model;

use SimpleORM\core\model\Model;

class Users extends Model
{
    	/*
        * * Basic configuration
        * These arguments are optionals
        * protected $table = 'users'; //just if the class name a table name are different
        * protected $pk = 'id'; //just if the primary key name is not id
      */	    	    
}

Creating a new user (without check)

$this->Users->create([
  'name' => 'Junior Oliveira',
  'email' => '[email protected]'
]);

Let the ORM choose if it will be created or updated. The ORM will execute the find method before to decide if will create or update data

Saving data

$this->Users->save([
  'id' => 1,
  'name' => 'Junior Oliveira'
]);

Retrieving the id

$this->Users->lastSavedId();

Updating a user with id = 1

$this->Users->update([
  'id' => 1,
  'email' => '[email protected]'
]);

Delete

$this->Users->delete(['id' => 1]);

Read

$this->Users->findAll(); // fetchAll

$this->Users->findOne(['email' => '[email protected]']);

$this->Users->findById($id);

Checking

$this->Users->exists($id);

in case of true, you cat get the data with:

$this->Users->fetch();

Functionalities if used as Framework

  • CRUD functions
  • Auto load Model classes in Controllers
  • To use the automatic functions you should use the filename and structure conventions
  • Just follow the example on /controller/UsersController.php
  • All controllers in /app/controllers folder
  • All models in /app/models folder

Convetions

  • All controllers in /app/controller path
  • All models in /app/model path
  • All views in /app/view path
  • Filenames and classes must has the same name
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].