PHP code example of edsononildo / orm

1. Go to this page and download the library: Download edsononildo/orm library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

edsononildo / orm example snippets





use Bonfim\ActiveRecord\ActiveRecord;

ActiveRecord::config('mysql:host=localhost;dbname=testdb', 'username', 'password');

// Retrieve all records
$posts = Post::all();

// Retrieve records with specific keys
$posts = Post::select(['title']);

// Find records with a condition
$posts = Post::find('WHERE id = ?', [1]);

$post = new Post();
$post->title = 'My first blog post!!';
$post->author_name = 'Edson Onildo';
$post->save();

$post = Post::find('WHERE `id` = ?', [1])[0];
echo $post->title; // 'My first blog post!!'
$post->title = 'Some title';
$post->save();

$post = Post::find('WHERE `id` = ?');
$post->delete();