PHP code example of roxblnfk / cycle-active-record
1. Go to this page and download the library: Download roxblnfk/cycle-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/ */
use Cycle\ActiveRecord\ActiveRecord;
use Cycle\Annotated\Annotation\Column;
use Cycle\Annotated\Annotation\Entity;
#[Entity(table: 'user')]
class User extends ActiveRecord
{
#[Column(type: 'primary', typecast: 'int')]
public int $id;
public function __construct(
#[Column(type: 'string')]
public string $name
) {}
}
$user1 = new User('Lia');
$user2 = new User('Zaza');
// Persisting
$user1->prepare();
$user2->save(); // Save current and prepared entities
// Find and delete
User::findByPK(10)?->delete();
// Delete multiple
$user1->prepareDeletion();
$user2->delete();
// Use SelectQuery
User::find()->where('id', '>', '10')->fetchData();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.