forked from oraoto/pib
-
-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
779e309
commit f0dc45e
Showing
13 changed files
with
80 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
docs/static/js/main.8d0b254d.js → docs/static/js/main.6e68d1a8.js
Large diffs are not rendered by default.
Oops, something went wrong.
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
docs/static/js/main.8d0b254d.js.map → docs/static/js/main.6e68d1a8.js.map
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<html> | ||
<body> | ||
<script async type = "module" src = "https://cdn.jsdelivr.net/npm/php-wasm@0.0.9-alpha-20/php-tags.mjs"></script> | ||
<script type = "text/php" data-stdout = "#output" data-stderr = "#error" | ||
data-ini = ' | ||
allow_url_include = on | ||
display_errors = off' | ||
data-imports = '{ | ||
"https://cdn.jsdelivr.net/npm/@electric-sql/pglite/dist/index.js": ["PGlite"] | ||
}'><?php | ||
$pdo = new PDO('pgsql:'); | ||
$createTable = $pdo->prepare(' | ||
CREATE TABLE IF NOT EXISTS posts ( | ||
id SERIAL PRIMARY KEY, | ||
userId INTEGER, | ||
title TEXT, | ||
body TEXT | ||
)'); | ||
|
||
$createTable->execute(); | ||
|
||
$posts = json_decode(file_get_contents('https://jsonplaceholder.typicode.com/posts')); | ||
|
||
$insertPost = $pdo->prepare('INSERT INTO posts (id, userId, title, body) VALUES (:id, :userId, :title, :body)'); | ||
foreach($posts as $post) { | ||
$insertPost->execute((array)$post); | ||
} | ||
|
||
$selectPosts = $pdo->prepare('SELECT * FROM posts WHERE userId = ?'); | ||
$selectPosts->execute([ 4 ]); | ||
$headers = false; | ||
|
||
echo '<table id = "postgres">'; | ||
while ($row = $selectPosts->fetch(PDO::FETCH_ASSOC)) { | ||
if (!$headers) { | ||
echo '<tr>'; | ||
echo join('', array_map(fn($x) => "<th>$x</th>", array_keys($row))); | ||
echo '</tr>'; | ||
$headers = true; | ||
} | ||
echo '<tr>'; | ||
echo join('', array_map(fn($x, $y) => "<td title = '$y'>$x</td>", $row, array_keys($row))); | ||
echo '</tr>'; | ||
} | ||
echo '</table>'; | ||
|
||
include "https://seanmorris.github.io/php-static-dev/phpinfo.php"; | ||
</script> | ||
|
||
<h1>php-wasm & pglite in html</h1> | ||
<p><a href = "https://github.com/seanmorris/php-wasm">https://github.com/seanmorris/php-wasm</a></p> | ||
<pre id = "error"></pre> | ||
<div id = "output"></div> | ||
</body> | ||
</html> |