Example #1
0
<?php

require "blog.php";
use Blog\DB;
// Fetch all posts
$posts = DB\get("posts", $conn);
view("index", array("posts" => $posts, "name" => "John Doe"));
Example #2
0
<?php

require 'functions.php';
use Blog\DB;
// Connect to the db
$conn = DB\connect($config);
if (!$conn) {
    die('Problem connecting to the db.');
}
/* Create a database/table in mysql 

/ CREATE DATABASE blog;
/ CREATE TABLE posts;
/ INSERT INTO posts(title, body) VALUES('TITLE 1', 'BODY 1');
/ INSERT INTO posts(title, body) VALUES('TITLE 2', 'BODY 2');

*/
// Fetch all the posts
$post = DB\get('posts', $conn);
// Filter through and display in the view
$view_path = 'views/index.view.php';
include 'views/layout.php';
Example #3
0
<?php

require 'functions.php';
use Blog\DB;
$conn = DB\connect($config);
if ($conn) {
    $users = DB\get('users', $conn);
} else {
    die('Could not connect');
}
?>
<!doctype html>
<html>
<head>
	<title></title>
</head>
<body>
	<?php 
if ($users) {
    foreach ($users as $user) {
        echo "<li>{$user['username']}</li>";
    }
} else {
    echo "No rows returned.";
}
?>
</body>
</html>