PHP code example of icehrm / php-active-record

1. Go to this page and download the library: Download icehrm/php-active-record 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/ */

    

icehrm / php-active-record example snippets



use MyORM\MySqlActiveRecord;

class File extends MySqlActiveRecord
{
    public $table = 'Files';
}

$connection = new \MyORM\MySqlActiveRecord();
// Host, Username, Password, Database
$res = $connection->Connect('127.0.0.1:10012', 'root', 'root', 'phpactiverecord');

// Save a file
$file = new File();
$file->name = 'Test';
$file->filename = 'Test';
$file->file_group = 'Test';
$file->Save();

// Load saved file
$file = new File();
$file->Load('name = ?', ['Test']);

// Find all files
$files = $file->Find();

// Find first 5 files
$files = $file->Find('1=1 LIMIT 5');

// Find all files having name 'Test'
$files = $file->Find('name = ?', ['Test1']);

// Update file
$file = new File();
$file->Load('name = ?', ['Test']);
$file->file_group = 'New Group';
$file->Save();

// Delete file
$file = new File();
$file->Load('name = ?', ['Test']);
$file->Delete();

// Run row query
$file = new File();
$file->DB()->execute('DELETE FROM Files');

bash
composer