-
-
Save dopsmain/a3a9304bc60091f49eac6d8ad24e13f2 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