PHP code example of flytachi / db-mapping

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

    

flytachi / db-mapping example snippets




declare(strict_types=1);

namespace App\Models;

use Flytachi\DbMapping\Attributes\Entity\Table;
use Flytachi\DbMapping\Attributes\Hybrid\Id;
use Flytachi\DbMapping\Attributes\Primal\Varchar;
use Flytachi\DbMapping\Attributes\Primal\Integer;
use Flytachi\DbMapping\Attributes\Additive\DefaultVal;
use Flytachi\DbMapping\Attributes\Additive\NullableIs;

#[Table(name: "users")]
class User
{
    #[Id]
    #[Integer]
    public int $id;

    #[Varchar(length: 255)]
    public string $name;

    #[Varchar(length: 255)]
    #[NullableIs(true)]
    #[DefaultVal("[email protected]")]
    public ?string $email;

    #[Integer]
    public int $age;
}