protected function buildZfAdapter() { $pdoCon = new Db\Adapter\Driver\Pdo\Connection(); $pdoCon->setResource($this->connection->resource()); $pdo = new Db\Adapter\Driver\Pdo\Pdo($pdoCon); $this->adapter = new Db\Adapter\Adapter($pdo); $this->sql = new Db\Sql\Sql($this->adapter); }
public static function fetchSchema(Connection $connection, $table_name) { $stmt = $connection->executeSql("PRAGMA table_info(`" . $table_name . "`);"); if (!($rows = $stmt->fetchAll(PDO::FETCH_ASSOC))) { return $stmt; } $table_data = $pri = $uni = []; $table_indexes = ['pri' => [], 'uni' => []]; foreach ($rows as $row) { $data = ['type' => $row['type'], 'default' => array_key_exists('default', $row) ? $row['default'] : '']; $table_data[$row['name']] = $data; if ($row['pk']) { $table_indexes['pri'][] = $row['name']; } } return [$table_data, $table_indexes]; }
public static function exists(Connection $connection, $tableName) { $sql = sprintf("SHOW TABLES LIKE '%s'", $tableName); return (bool) $connection->selectValue($sql); }