1. Go to this page and download the library: Download initorm/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/ */
initorm / orm example snippets
namespace App\Model;
class Posts extends \InitORM\ORM\Model
{
/**
* If your model will use a connection other than your global connection, provide connection information.
* @var array|null <p>Default : NULL</p>
*/
protected array $credentials = [
'dsn' => '',
'username' => 'root',
'password' => '',
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
];
/**
* If not specified, \InitORM\ORM\Entity::class is used by default.
*
* @var string<\InitORM\ORM\Entity>
*/
protected $entity = \App\Entities\PostEntity::class;
/**
* If not specified, the name of your model class is used.
*
* @var string
*/
protected string $schema = 'posts';
/**
* The name of the PRIMARY KEY column.
*
* @var string
*/
protected string $schemaId = 'id';
/**
* Specify FALSE if you want the data to be permanently deleted.
*
* @var bool
*/
protected bool $useSoftDeletes = true;
/**
* Column name to hold the creation time of the data.
*
* @var string|null
*/
protected ?string $createdField = 'created_at';
/**
* The column name to hold the last time the data was updated.
*
* @var string|null
*/
protected ?string $updatedField = 'updated_at';
/**
* Column name to keep deletion time if $useSoftDeletes is active.
*
* @var string|null
*/
protected ?string $deletedField = 'deleted_at';
protected bool $readable = true;
protected bool $writable = true;
protected bool $deletable = true;
protected bool $updatable = true;
}
namespace App\Entities;
class PostEntity extends \InitORM\ORM\Entity
{
/**
* An example of a getter method for the "post_title" column.
*
* Usage :
* echo $entity->post_title;
*/
public function getPostTitleAttribute($title)
{
return strtoupper($title);
}
/**
* An example of a setter method for the "post_title" column.
*
* Usage :
* $entity->post_title = 'New Post Title';
*/
public function setPostTitleAttribute($title)
{
$this->post_title = strtolower($title);
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.