Last active
November 26, 2017 06:32
-
-
Save dylanburkey/11254434 to your computer and use it in GitHub Desktop.
Slim MySQLi Integration
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
<?php | |
require 'Slim/Slim.php'; | |
\Slim\Slim::registerAutoloader(); | |
$app = new \Slim\Slim(); $app->get('/', function () use ($app) { | |
require_once 'lib/mysql.php'; | |
$db = connect_db(); | |
$result = $db->query( 'SELECT id, name, job FROM friends;' ); | |
while ( $row = $result->fetch_array(MYSQLI_ASSOC) ) { | |
$data[] = $row; | |
} | |
$app->render('friends.php', array( | |
'page_title' => "Your Friends", | |
'data' => $data | |
) | |
); | |
}); | |
$app->run(); |
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
<?php | |
require 'Slim/Slim.php'; | |
\Slim\Slim::registerAutoloader(); | |
$app = new \Slim\Slim(); $app->get('/', function () use ($app) { | |
require_once 'lib/mysql.php'; | |
$db = connect_db(); | |
$result = $db->query( 'SELECT id, name, job FROM friends;' ); | |
while ( $row = $result->fetch_array(MYSQLI_ASSOC) ) { | |
$data[] = $row; | |
} | |
$app->render('friends.php', array( | |
'page_title' => "Your Friends", | |
'data' => $data | |
) | |
); | |
}); | |
$app->run(); |
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
$app->get('/', function () use ($app) { | |
require_once '../lib/dbconnect.inc.php'; | |
$db = dbConnect('read'); | |
$result = $db->query( 'SELECT * FROM le_pages;' ); | |
while ( $row = $result->fetch_array(MYSQLI_ASSOC) ) { | |
$data[] = $row; | |
} | |
$app->render('index.html', array( | |
'page_title' => "Your Friends", | |
'data' => $data | |
) | |
); | |
}); | |
$app->run(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment