/**
  * @depends testExecute
  */
 public function testGetRecord()
 {
     $data['username'] = '******';
     $data['email'] = '*****@*****.**';
     $data['developer'] = 'Y';
     $this->assertEquals($data, $this->db->getRecord('SELECT username, email, developer FROM users WHERE id = ?', 1337));
     $this->assertEquals($data, $this->db->getRecord('SELECT username, email, developer FROM users WHERE id = :id', array(':id' => 1337)));
 }
 /**
  * Get the list of columns.
  *
  * @return	array
  */
 public function getColumns()
 {
     // has results
     if ($this->numResults != 0) {
         // build query
         switch ($this->db->getDriver()) {
             case 'mysql':
                 $query = substr_count($this->query, 'LIMIT ') > 0 ? $this->query : $this->query . ' LIMIT 1';
                 break;
             default:
                 throw new SpoonDataGridException('No datagrid support has been written for this database backend (' . $this->db->getDriver() . ')');
                 break;
         }
         // fetch record
         $record = $this->db->getRecord($query, $this->queryParameters);
         // fetch columns
         return array_keys($record);
     }
 }
// set include path
ini_set("include_path", ".:../library/");
// required classes
require_once 'spoon/spoon.php';
require_once 'publicApp/publicApp.php';
$tpl = new SpoonTemplate();
$tpl->setForceCompile(true);
$tpl->setCompileDirectory('./compiled_templates');
// do I know you?
if (SpoonSession::exists('public_uid')) {
    $tpl->assign('oLogout', true);
    // show the output of get()
    $uid = SpoonSession::get('public_uid');
    // make a connection
    $db = new SpoonDatabase('mysql', 'localhost', 'xqdchsmn_public', 'pRAcHU8Ajath7qa3', 'xqdchsmn_public');
    $user = $db->getRecord('SELECT * FROM users WHERE user_id = ?', $uid);
    //Spoon::dump($user);
    if ($user['fb_uid'] != null) {
        $tpl->assign('fbu', $user['fb_uid']);
    } else {
        $tpl->assign('fbu', 1);
    }
    $tpl->assign('uname', $user['username']);
    $tpl->assign('firstname', $user['first_name']);
    $tpl->assign('lastname', $user['last_name']);
    $tpl->assign('email', $user['mail']);
    //spoon::dump($user);
    //$tpl->assign('gender', $user['gender']);
    //$tpl->assign('weight', $user['weight']);
    //  $tpl->assign('birth', $user['birth_date']);
    //$tpl->assign('password', $user['password']);
Exemple #4
0
 /**
  * Get the list of columns.
  *
  * @return	array
  */
 public function getColumns()
 {
     // has results
     if ($this->numResults != 0) {
         // build query
         switch ($this->db->getDriver()) {
             case 'mysql':
                 // @todo davy - this might also be LIMIT with a tab before or after instead of a space, use a decent regular expression to fix this.
                 $query = substr_count($this->query, 'LIMIT ') > 0 ? $this->query : $this->query . ' LIMIT 1';
                 break;
             default:
                 throw new SpoonDataGridException('No datagrid support has been written for this database backend (' . $this->db->getDriver() . ')');
                 break;
         }
         // fetch record
         $record = $this->db->getRecord($query, $this->queryParameters);
         // fetch columns
         return array_keys($record);
     }
 }
Exemple #5
0
<?php

date_default_timezone_set('Europe/Berlin');
// set include path
ini_set("include_path", ".:../library/");
// required classes
require_once 'spoon/spoon.php';
require_once 'publicApp/publicApp.php';
// facebook php
require_once 'facebook/facebook.php';
// Create our Application instance (replace this with your appId and secret).
$facebook = new Facebook(array('appId' => '177481728946474', 'secret' => '6d5db3a0e538eb5aa7bebe6ae0bb2efe', 'cookie' => true));
$session = $facebook->getSession();
// Session based API call.
if ($session) {
    try {
        $fb_uid = $facebook->getUser();
        $db = new SpoonDatabase('mysql', 'localhost', 'xqdchsmn_public', 'pRAcHU8Ajath7qa3', 'xqdchsmn_public');
        $var = $db->getRecord('SELECT * FROM users WHERE fb_uid = ?', $fb_uid);
        if (!empty($var)) {
            spoonSession::start();
            SpoonSession::set('public_uid', $var['user_id']);
            SpoonHTTP::redirect('dashboard.php');
        } else {
            SpoonHTTP::redirect('register.php');
        }
    } catch (FacebookApiException $e) {
        error_log($e);
    }
}
Exemple #6
0
date_default_timezone_set('Europe/Berlin');
// set include path
ini_set("include_path", ".:../library/");
// required classes
require_once 'spoon/spoon.php';
require_once 'publicApp/publicApp.php';
$tpl = new SpoonTemplate();
$tpl->setForceCompile(true);
$tpl->setCompileDirectory('./compiled_templates');
// do I know you?
if (SpoonSession::exists('public_uid')) {
    $tpl->assign('oLogout', true);
    $tpl->assign('oNavMe', true);
    $uid = SpoonSession::get('public_uid');
    $db = new SpoonDatabase('mysql', 'localhost', 'xqdchsmn_public', 'pRAcHU8Ajath7qa3', 'xqdchsmn_public');
    $user = $db->getRecord('SELECT * FROM users WHERE user_id = ?', $uid);
    $tpl->assign('uname', $user['username']);
    if ($user['fb_uid'] != null) {
        $tpl->assign('fbu', $user['fb_uid']);
    } else {
        $tpl->assign('fbu', 1);
    }
    $lastChecking = $db->getRecord('SELECT * FROM checkins WHERE user_id = ? ORDER BY timestamp DESC', $uid);
    $lastPub = $db->getRecord('SELECT * FROM pubs WHERE pub_id = ?', $lastChecking['pub_id']);
    $tpl->assign('lastPub', $lastPub['name']);
    $tpl->assign('lastPubId', $lastPub['pub_id']);
    $tpl->assign('lastDate', SpoonDate::getTimeAgo(strtotime($lastChecking['timestamp'])));
    /*code max*/
    $recentDrinks = PublicApp::getRecentDrinks();
    $recentCheckins = PublicApp::getRecentCheckins();
    $recent = array_merge($recentDrinks, $recentCheckins);