/** * The model's constructor method. * * @param Connection|null $connection An Opeyemiabiodun\PotatoORM\Connections\Connection instance or null * @param string $table The name of the model's table in the database */ public function __construct($array = [], Connection $connection = null, $table = null) { if (null === $connection) { $connection = ConnectionFactory::load(); } if (null === $table) { $table = strtolower(substr(get_class($this), strripos(get_class($this), '\\') + 1)) . '_table'; } $this->setConnection($connection); $this->setTable($table); if (!empty($array)) { $this->setProperties($array); } }
public function __construct($name = null, array $data = [], $dataName = '') { parent::__construct($name, $data, $dataName); $this->pdo = ConnectionFactory::load()->getPdo(); User::createTable($this->pdo); }