PHP code example of notyes / php-active-record

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

    

notyes / php-active-record example snippets


// Include
use ActiveRecord\ActiveDatabase;

...

// Create Database configs
$db_config = array(
    'hostname' => "localhost",
    'username' => "username",
    'password' => "password",
    'database' => "database_name",
    'dbdriver' => "mysql",
    'pconnect' => FALSE,
    'db_debug' => TRUE
);

// Add Config and give it a name
ActiveDatabase::addConfig("read", $db_config);

//Use the named connection
$query = ActiveDatabase::get("read")->get('table_name')
$row = $query->result_array();
print_r($row);

$this->db

ActiveDatabase::get("db_reference_name")