PHP code example of m.rahimi / astro-orm
1. Go to this page and download the library: Download m.rahimi/astro-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/ */
m.rahimi / astro-orm example snippets
connect(); // Which implements database connection
getConnection(); // Which return database connection
$this->config = $this->getConfigs('database', 'astro_orm');
$pdoConnection = new PDODatabaseConnection($this->config);
$pdoHandler = $pdoConnection->connect();
$data = [
'name' => 'John',
'email' => '[email protected] ',
'link' => 'https://example.com',
'skill' => 'PHP'
];
$last_id = PDOQueryBuilder::table('users')->create($data);
$result = PDOQueryBuilder::table('users')
->where('name', 'John')
->where('skill', 'PHP')
->update([
'skill' => 'Javascript',
'name' => 'Jeff',
'email' => '[email protected] '
]);
$result = PDOQueryBuilder::table('users')
->where('name', 'John')
->where('skill', 'JS')
->update(['skill' => 'Javascript']);
$result = PDOQueryBuilder::table('users')
->orWhere('skill', 'PHP')
->orWhere('skill', 'JS')
->get();
$result = PDOQueryBuilder::table('users')
->where('name', 'John')
->delete();
$result = PDOQueryBuilder::table('users')
->where('name', 'John')
->where('skill', 'Javascript')
->get();
$result = PDOQueryBuilder::table('users')
->where('name', 'First Row')
->first();
$result = PDOQueryBuilder::table('users')
->where('name', 'Jim')
->firstOrFail();
$result = PDOQueryBuilder::table('users')
->find($id);
$result = PDOQueryBuilder::table('users')
->findOrFail($id);
$result = PDOQueryBuilder::table('users')
->findBy('name', 'Jack');
$result = PDOQueryBuilder::table('users')
->where('name', 'Jack')
->limit(5)
->get();
$result = PDOQueryBuilder::table('users')
->orderBy('skill', 'DESC')
->get();
composer test
config/database.php