1. Go to this page and download the library: Download sobhanmohammadi/arxaron 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/ */
Database::transaction(function ($conn) {
$conn->execute('UPDATE accounts SET balance = balance - ? WHERE id = ?', [100, 1]);
$conn->execute('UPDATE accounts SET balance = balance + ? WHERE id = ?', [100, 2]);
});
$topProducts = Database::table('products')
->where('active', '=', 1)
->orderBy('sales', 'DESC')
->limit(10)
->cache(ttlSeconds: 60) // cached under a key tagged with "products"
->get();
// Any insert/update/delete on `products` automatically invalidates
// everything cached under that tag.
use Arxaron\Model;
final class User extends Model
{
protected static string $table = 'users';
protected static array $fillable = ['name', 'email'];
protected static ?int $cacheTtl = 30;
}
$user = User::create(['name' => 'Ada', 'email' => '[email protected]']);
$user = User::find(1);
$user->name = 'Ada Lovelace';
$user->save();
$user->delete();
foreach (User::query()->where('active', '=', 1)->get() as $row) {
// ...
}
foreach (Database::connection()->cursor('SELECT * FROM events') as $row) {
// processed one row at a time, not buffered in memory
}