PHP code example of jstark518 / phpsimpleorm

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

    

jstark518 / phpsimpleorm example snippets


use SimpleORM\DB_Config;
use SimpleORM\Model;

tConfig()->host = "localhost";
DB_Config::getConfig()->user = "root";
DB_Config::getConfig()->password = "";
DB_Config::getConfig()->db = "db";
DB_Config::getConfig()->onError = function($query, $e) {
    echo "$query failed:<br>";
    echo $e->error;
};

$users = Users::All();
foreach($users as $user) {
    echo $user->name;
}