Example #1
0
require_once('Database.php');

$db = new Database($db_info);

echo '<pre>';
$db->query("
	SELECT *
	FROM md_languages");
print_r($db->assoc());
$db->free_result();


$db->query("
	SELECT *
	FROM md_languages");
print_r($db->row());
$db->free_result();

$db->query("
	SELECT *
	FROM md_languages");
print_r($db->row());
$db->free_result();

$db->query("
	SELECT *
	FROM md_languages");
print_r($db->row());
$db->free_result();

$db->query("
Example #2
0
$path = realpath(dirname());
require $path . "/database.class.php";
// Creates the instance
$db = new Database();
// 3 ways to bind parameters :
// 1. Read friendly method
//$db->bind("firstname","John");
//$db->bind("age","19");
// 2. Bind more parameters
//$db->bindMore(array("firstname"=>"John","age"=>"19"));
// 3. Or just give the parameters to the method
//$db->query("SELECT * FROM Persons WHERE firstname = :firstname AND age = :age", array("firstname"=>"John","age"=>"19"));
//  Fetching data
//$person 	 =     $db->query("SELECT * FROM users");
$single = $db->row("SELECT firstname FROM users WHERE Id = :id ", array('id' => '2'));
/*
	// If you want another fetchmode just give it as parameter
	$persons_num =     $db->query("SELECT * FROM Persons", null, PDO::FETCH_NUM);
// Fetching single value
	$firstname	 =     $db->single("SELECT firstname FROM Persons WHERE Id = :id ", array('id' => '3' ) );
// Single Row
	$id_age 	 =     $db->row("SELECT Id, Age FROM Persons WHERE firstname = :f", array("f"=>"Zoe"));
		
	// Single Row with numeric index
	$id_age_num  =     $db->row("SELECT Id, Age FROM Persons WHERE firstname = :f", array("f"=>"Zoe"),PDO::FETCH_NUM);
// Column, numeric index
	$ages  		 =     $db->column("SELECT age FROM Persons");

	// The following statemens will return the affected rows
// Update statement
            }
        }
    }
}
$dir = dirname(__FILE__) . '/..';
require_once '../server/database/database.php';
require_once '../server/config.php';
$db = new Database($db_path);
$id = $db->escape($_GET['id']);
// If more than one id was passed, parse them out
$shift_ids = array();
if (preg_match("/,/", $id)) {
    $shift_ids = split(',', $id);
    $id = $shift_ids[0];
}
$shift = $db->row("\n  SELECT *\n  FROM shift\n  WHERE url_slug = '{$id}'\n");
$myurl = $shift->href;
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $myurl);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_COOKIE, 1);
$useragent = "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.0.1) Gecko/2008070206 Firefox/3.0.1";
curl_setopt($curl, CURLOPT_USERAGENT, $useragent);
$result = curl_exec($curl);
curl_close($curl);
if (!$result) {
    $result = "Page not found.";
    echo "<p style=\"color:#DD6666;font-size:1em;font-family:Verdana,Helvetica,sans-serif;\">" . $result . "</p>";
    exit;
}
Example #4
0
$db_filename = '';
if (preg_match('#sqlite://(.+)#', $db_path, $matches)) {
    list(, $db_filename) = $matches;
}
$db = new Database($db_path);
if ($db->tables() == array()) {
    // Setup the initial database configuration
    $db->setup("{$dir}/server/init.sql");
    $db->query("\n    INSERT INTO user\n    (username, status)\n    VALUES ('shiftspace', 1)\n  ");
}
// Set up the user session
session_register('user');
$user = $_SESSION['user'];
if (empty($user) && !empty($_COOKIE['auth'])) {
    list($username, $password) = explode(':', $_COOKIE['auth']);
    $user = $db->row("\n    SELECT *\n    FROM user\n    WHERE username = '******'\n    AND password = '******'\n  ");
    if (!empty($user)) {
        $_SESSION['user'] = $user;
    }
}
if (!empty($_GET['v'])) {
    $client_version = $_GET['v'];
}
$server = 'http://' . $_SERVER['SERVER_NAME'] . dirname($_SERVER['PHP_SELF']) . '/';
if (get_magic_quotes_gpc()) {
    function strip_quotes(&$var)
    {
        if (is_array($var)) {
            array_walk($var, 'strip_quotes');
        } else {
            $var = stripslashes($var);