public function __construct($name, Connection $driver) { $this->name = $name; $this->fields = new Collection(); if ($driver->isConnected()) { try { if ($driver->getDriverName() == "sqlite") { $stmt = $driver->raw("SELECT sql FROM sqlite_master WHERE name='{$name}'"); } else { $stmt = $driver->raw('DESC ' . $name); } if ($stmt != null) { if ($stmt->execute()) { $stmt->setFetchMode(\PDO::FETCH_CLASS, 'Simplified\\Database\\Schema\\TableField'); while ($record = $stmt->fetch()) { if ($name == "user_groups") { var_dump($record); } $this->fields[$record->field] = $record; } } } } catch (\PDOException $e) { throw new DriverException("Unable to fetch table schema: " . $e->getMessage()); } } }
public function build(Connection $conn) { $sql = $this->toSql(); return strlen($sql) > 0 ? $conn->raw($sql) : false; }