Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require '../settings.php';
- class Db {
- protected static $instance = null;
- public static function getInstance()
- {
- if (is_null(self::$instance)) {
- self::$instance = new self();
- }
- return self::$instance;
- }
- }
- // Tada galime naudoti
- try
- {
- $handler = new PDO('mysql:host=localhost;dbname=mistic_rpe', login, password);
- $handler ->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- }catch (PDOException $e) {
- echo "pagavo";
- }
- //$result = Db::getInstance()->query($sql);
- /*
- function execute($sql){
- $result = mysql_query($sql);
- return true;
- if (!$result) {
- return false;
- }
- }
- execute('CREATE DATABASE my_db;');
- */
- function execute($sql)
- {
- $query = $handler->query('SELECT * FROM Bandymas');
- while ($r = $query->fetch()) {
- echo $r['name'], "<br>";
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement