Exemplo n.º 1
0
    public function getCountReadedMessages()
    {
        $sql = $this->getQuery('select count(*) from ' . self::$SCHEMA . '.MSG INNER JOIN ' . self::$SCHEMA . '.MSG_BOX ON"ID"="MSG_ID" WHERE
								"To_User_ID"=' . $this->userId . ' AND "Status"=' . self::$READED);
        $stmt = $this->pdo->query($sql);
        $row = $stmt->fetch();
        return $row['count'];
    }
Exemplo n.º 2
0
 /**
 * The garbage collector deletes all sessions from the database
 * that where not deleted by the session_destroy function.
 * so your session table will stay clean.
 *
 * @access public
 * @access Integer $maxlifetime The maximum session lifetime
 * @return Boolean
 */
 public function gc($maxlifetime)
 {
     // Set a period after that a session pass off.
     $maxlifetime = strtotime("-20 minutes");
     // Setup a query to delete discontinued sessions, ...
     $delete = "DELETE FROM `sessions` WHERE `sessions`.`last_updated` < :maxlifetime;";
     $result = $this->pdo->query($delete, array("maxlifetime" => $maxlifetime));
     return $result;
 }
Exemplo n.º 3
0
 public static function getAll()
 {
     $lijst = array();
     $dbh = new pdo(dbconfigpizzeria::$DB_CONNSTRING, dbconfigpizzeria::$DB_USERNAME, dbconfigpizzeria::$DB_PASSWORD);
     $sql = "select * from klanten";
     $resultSet = $dbh->query($sql);
     foreach ($resultSet as $rij) {
         $pizza = new Pizza($rij["voornaam"], $rij["familienaam"], $rij["email"], $rij["wachtwoord"]);
         $lijst[] = $pizza;
     }
     $dbh = null;
     return $lijst;
 }
Exemplo n.º 4
0
 public static function getAll()
 {
     $lijst = array();
     $dbh = new pdo(dbconfigpizzeria::$DB_CONNSTRING, dbconfigpizzeria::$DB_USERNAME, dbconfigpizzeria::$DB_PASSWORD);
     $sql = "select * from extras";
     $resultSet = $dbh->query($sql);
     foreach ($resultSet as $rij) {
         $extra = new Extra($rij["extraid"], $rij["omschrijving"], $rij["prijs"]);
         $lijst[] = $extra;
     }
     $dbh = null;
     return $lijst;
 }
Exemplo n.º 5
0
 public static function getAll()
 {
     $lijst = array();
     $dbh = new pdo(dbconfigpizzeria::$DB_CONNSTRING, dbconfigpizzeria::$DB_USERNAME, dbconfigpizzeria::$DB_PASSWORD);
     $sql = "select * from pizzas";
     $resultSet = $dbh->query($sql);
     foreach ($resultSet as $rij) {
         $pizza = new Pizza($rij["pid"], $rij["pnaam"], $rij["pomsch"], $rij["prijs"]);
         $lijst[] = $pizza;
     }
     $dbh = null;
     return $lijst;
 }
Exemplo n.º 6
0
 /**
  * Restauration d'un fichier
  * 
  * @param string $file
  */
 protected function restoreMysql($file)
 {
     try {
         // Ouverture du fichier à restaurer
         $this->gz_file = @gzopen(SITE_ROOT . DS . 'App' . DS . 'Migrations' . DS . $file, 'r');
         // Lecture et stockage des commandes
         $string = '';
         while (!gzeof($this->gz_file)) {
             $string .= gzread($this->gz_file, 4096);
         }
         $fetchData = explode(";\n", $string);
         // Connexion et envoi des commandes de restauration
         $this->cnxBdd();
         foreach ($fetchData as $cmd) {
             $this->mysql->query($cmd . ";");
         }
         $this->helper('Restoration complete !');
     } catch (\PDOException $e) {
         $this->helper($e->getMessage(), 'error');
     }
 }
Exemplo n.º 7
0
<?php

try {
    $db = new pdo('mysql:unix_socket=/cloudsql/bovinetracker:bovinetracker;dbname=bovinetracker', 'root', '');
} catch (PDOException $ex) {
    die(json_encode(array('outcome' => false, 'message' => 'Unable to connect.')));
}
try {
    // Show existing cattle
    foreach ($db->query('SELECT * from cows') as $row) {
        echo "<div><strong>" . $row['tag'] . "</strong> " . $row['breed'] . "</div>";
    }
} catch (PDOException $ex) {
    echo "An error occurred in reading or writing to guestbook.";
}
$db = null;
Exemplo n.º 8
0
<?php

$db = new pdo('sqlite::memory:');
$db->beginTransaction();
$db->query('CREATE TABLE IF NOT EXISTS foobar (id INT AUTO INCREMENT, name TEXT)');
$db->commit();
$db->beginTransaction();
$db->query('INSERT INTO foobar VALUES (NULL, "PHP")');
$db->query('INSERT INTO foobar VALUES (NULL, "PHP6")');
$db->rollback();
$r = $db->query('SELECT COUNT(*) FROM foobar');
var_dump($r->rowCount());
$db->query('DROP TABLE foobar');
Exemplo n.º 9
0
<?php

echo "this is a database test.";
$ip = '192.168.33.61';
$port = '3306';
$user = '******';
$pass = '';
$info = sprintf("mysql:host=%s;port=%s,database=;", $ip, $port);
$db = new pdo($info, $user, $pass, array(PDO::ATTR_PERSISTENT => true, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$db->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
$sth = $db->query('use test_database');
$sth = $db->prepare('select * from fukens');
$sth->execute(array());
while ($line = $sth->fetch()) {
    var_dump($line);
}
exit;
Exemplo n.º 10
0
/**
 * Created by PhpStorm.
 * User: niwa
 * Date: 2014/09/09
 * Time: 11:18
 */
echo "this is a shop_cart test.\n";
$ip = '127.0.0.1';
$port = '3306';
$user = '******';
$pass = '';
$info = sprintf("mysql:host=%s;port=%s,database=;", $ip, $port);
$db = new pdo($info, $user, $pass, array(PDO::ATTR_PERSISTENT => true, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$db->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
$db->query('use shop_cart');
/*
$sth = $db->prepare('select * from user');
$sth->execute(array());
$user = array();
while ($line = $sth->fetch()) {
    $user[$line['id']] = $line;
}
$sth->closeCursor();
*/
$sth_buy = $db->prepare('select * from buy');
$sth_buy_item = $db->prepare('select * from buy_item where buycd = ?');
$sth_item_list = $db->prepare('select * from item_list where itemcd= ?');
$sth_user = $db->prepare('select * from user where id = ?');
$sth_buy->execute(array());
while ($line_buy = $sth_buy->fetch()) {
Exemplo n.º 11
0
				<div id="info_file">
			
					<div id="title"   ><a href="play.php?metodo=file&id=' . $value['file'] . '&title=' . $value['label'] . '" target="control"> &ensp;&ensp;&ensp; ' . $caneleTV . '</a></div> 
					<div id="playlist"></div>
					<div id="type"    >' . $informazioni . '</div>
					
				</div>
				
				
				';
        }
    } else {
        $caneleTV = $value['label'];
        $connection = new pdo("sqlite:Epg4.db");
        $query = "SELECT * FROM epg WHERE sName LIKE '{$caneleTV}' ";
        $result = $connection->query($query);
        $row = $result->fetch(PDO::FETCH_ASSOC);
        //print_r($row);
        $canale_ora = $row['idEpg'];
        $time_now = strtotime("now");
        //echo $time_now;
        $query1 = "\n\t\t\t\t\n\t\t\t\tSELECT *\n\t\t\t\tFROM 'epgtags' \n\t\t\t\tWHERE idEpg LIKE '{$canale_ora}' AND iStartTime >= '{$time_now}'\n\t\t\t\tLIMIT 1\n\t\t\t\t\n\t\t\t\t";
        $result1 = $connection->query($query1);
        $row1 = $result1->fetch(PDO::FETCH_ASSOC);
        $informazioni = $row1['sTitle'];
        $descrizione = $row1['sPlot'];
        echo '
				
				
				<div id="info_file">
			
Exemplo n.º 12
0
<body>
<div id="header">
    <h1>Art Gallery</h1>
    <p>Joseph Sanchez and Christy Lentz -- CSCI 3287 Fall 2015</p>
</div>

<p><a href='/'>Home</a></p>

<?php 
$conn = null;
if (isset($_SERVER['SERVER_SOFTWARE']) && strpos($_SERVER['SERVER_SOFTWARE'], 'Google App Engine') !== false) {
    // Connect from App Engine.
    try {
        $conn = new pdo('mysql:unix_socket=/cloudsql/artgallery-1156:art;dbname=artgallery', 'root', '');
    } catch (PDOException $ex) {
        die(json_encode(array('outcome' => false, 'message' => 'Unable to connect :((((')));
    }
} else {
    // Connect from a development environment.
    try {
        $conn = new pdo('mysql:host=173.194.105.221;dbname=artgallery', 'joseph', 'admin');
    } catch (PDOException $ex) {
        die(json_encode(array('outcome' => false, 'message' => 'Unable to connect')));
    }
}
echo "<h2>Available Pieces</h2>";
echo "<table style='width:50%'>";
foreach ($conn->query('select * from art_pieces where pieceid not in (select pieceid from purchases)') as $row) {
    echo "<tr><td><a href='/availDetail.php?id=" . $row[pieceid] . "'>" . $row[name] . "</a></td></tr>";
    //echo "<p><a href='piece.php?id=" . $row[pieceid] . "'>" . $row["name"] . "</a></p>";
}
Exemplo n.º 13
0
</head>
<body onload="prettyPrint()">
<!-- ######### ######### ######### bbody ######### ######### ######### -->
    <div style="float:right;"><img src="./img/logo.gif" title="LOGO" alt="LOGO" /></div>
    <h1>步步街 商品信息 CSV 生成器</h1>
    <hr />
    <h3>输出的CSV</h3>
<?php 
try {
    // SQLite3的PDO连接
    $dsn = 'sqlite:九红产品.bbj';
    $dbh = new pdo($dsn);
    $query = 'SELECT * FROM "商品之贺兰山"';
    $sep = ';';
    echo '<pre class="prettyprint linenums">';
    foreach ($dbh->query($query) as $result) {
        $csvBody = "\n";
        $csvBody .= $result['ID'] + 9;
        // 01 【ID】
        $csvBody .= $sep . $result['是否在售'];
        // 02 【是否启用】
        $csvBody .= $sep . $result['商品名称'];
        // 03 【商品名称】
        $csvBody .= $sep . '1,2';
        // 04 【商品分类】
        $csvBody .= $sep . $result['售价'];
        // 05 【售价】
        $csvBody .= $sep . '0';
        // 06 【计税规则ID】
        $csvBody .= $sep . $result['供价'];
        // 07 【批发价】
Exemplo n.º 14
0
<?php

$db = new pdo('sqlite::memory:');
$db->query('CREATE TABLE IF NOT EXISTS foo (id INT AUTO INCREMENT, name TEXT)');
$db->query('INSERT INTO foo VALUES (NULL, "PHP")');
$db->query('INSERT INTO foo VALUES (NULL, "PHP6")');
var_dump($db->query('SELECT * FROM foo'));
var_dump($db->errorInfo());
var_dump($db->lastInsertId());
$db->query('DROP TABLE foo');
Exemplo n.º 15
0
<?php

$db = new pdo('sqlite::memory:');
$db->query('CREATE TABLE IF NOT EXISTS foobar (id INT AUTO INCREMENT, name TEXT)');
$db->query('INSERT INTO foobar VALUES (NULL, "PHP")');
$db->query('INSERT INTO foobar VALUES (NULL, "PHP6")');
$db->sqliteCreateFunction('testing', function ($v) {
    return strtolower($v);
});
foreach ($db->query('SELECT testing(name) FROM foobar') as $row) {
    var_dump($row);
}
$db->query('DROP TABLE foobar');
Exemplo n.º 16
0
<?php

$db = new pdo('sqlite::memory:');
$x = $db->query('select 1 as queryStringxx');
$y = $x->fetch(PDO::FETCH_LAZY);
var_dump($y, $y->queryString, $y->queryStringzz, $y->queryStringxx);
print "---\n";
var_dump($y[5], $y->{3});
Exemplo n.º 17
0
echo "<table class=simpletable border=1>";
echo "<tr><th align=left>Name</th><th>Poste</th></tr>";
while ($row = mysql_fetch_assoc($result)) {
    echo "<tr><td align=left>" . $row['nom'] . "</td>";
    echo "<td align=center class=addCommas>" . $row['fonction'] . "</td></tr>";
}
echo "</table>";
echo "</table>";
*/
// Connect from App Engine.
try {
    $db = new pdo('mysql:unix_socket=/cloudsql/uptilab.com:moonlit-premise-638:callcatcher-sql;dbname=prod', 'antonin', 'uptilab95');
} catch (PDOException $ex) {
    die(json_encode(array('outcome' => false, 'message' => 'Unable to connect.')));
}
$reponse = $db->query('SELECT * FROM display_number_hunter');
while ($donnees = $reponse->fetch()) {
    echo $donnees['display'] . '<br />';
}
$reponse->closeCursor();
?>


<!-- Style the results table -->
<style type="text/css">
h3 {font-family:verdana;font-size:24px;color:#181C26;}
table.simpletable {font-family:verdana;font-size:15px;color:#40434A;border-width:1px;border-color:#778AB8;border-collapse:collapse;}
table.simpletable th {border-width: 1px;padding: 10px;border-style: solid;border-color:#778AB8;background-color:#dedede;}
table.simpletable td {border-width: 1px;padding: 10px;border-style: solid;border-color: #778AB8;background-color: #ffffff;}
</style>
Exemplo n.º 18
0
<?php

$db = new pdo('sqlite::memory:');
$x = $db->query('select 1 as queryString');
var_dump($x, $x->queryString);
$y = $x->fetch();
var_dump($y, @$y->queryString);
print "--------------------------------------------\n";
$x = $db->query('select 1 as queryString');
var_dump($x, $x->queryString);
$y = $x->fetch(PDO::FETCH_LAZY);
var_dump($y, $y->queryString);
Exemplo n.º 19
0
<?php

$db = new pdo('sqlite::memory:');
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$db->query('CREATE TABLE IF NOT EXISTS foobar (id INT AUTO INCREMENT, name TEXT)');
$db->query('INSERT INTO foobar VALUES (NULL, "1")');
$db->query('INSERT INTO foobar VALUES (NULL, "2")');
$db->query('INSERT INTO foobar VALUES (NULL, "10")');
$db->sqliteCreateCollation('MYCOLLATE', function ($a, $b) {
    return strnatcmp($a, $b);
});
$result = $db->query('SELECT name FROM foobar ORDER BY name COLLATE MYCOLLATE');
foreach ($result as $row) {
    echo $row['name'] . "\n";
}
$result = $db->query('SELECT name FROM foobar ORDER BY name');
foreach ($result as $row) {
    echo $row['name'] . "\n";
}
$db->query('DROP TABLE foobar');
Exemplo n.º 20
0
<body>
<div id="header">
    <h1>Art Gallery</h1>
    <p>Joseph Sanchez and Christy Lentz -- CSCI 3287 Fall 2015</p>
</div>

<p><a href='/'>Home</a></p>

<?php 
$conn = null;
if (isset($_SERVER['SERVER_SOFTWARE']) && strpos($_SERVER['SERVER_SOFTWARE'], 'Google App Engine') !== false) {
    // Connect from App Engine.
    try {
        $conn = new pdo('mysql:unix_socket=/cloudsql/artgallery-1156:art;dbname=artgallery', 'root', '');
    } catch (PDOException $ex) {
        die(json_encode(array('outcome' => false, 'message' => 'Unable to connect :((((')));
    }
} else {
    // Connect from a development environment.
    try {
        $conn = new pdo('mysql:host=173.194.105.221;dbname=artgallery', 'joseph', 'admin');
    } catch (PDOException $ex) {
        die(json_encode(array('outcome' => false, 'message' => 'Unable to connect')));
    }
}
echo "<h2>Purchased Pieces</h2>";
echo "<table style='width:50%'>";
foreach ($conn->query('select art_pieces.name, purchases.purchaseid from art_pieces, purchases where art_pieces.pieceid=purchases.pieceid') as $row) {
    echo "<tr><td><a href='purchDetail.php?id=" . $row[purchaseid] . "'>" . $row[name] . "</a></td></tr>";
}
Exemplo n.º 21
0
 /**
  * reset all product
  *
  * @return boolean
  */
 public function reset()
 {
     $sql = sprintf("UPDATE %s SET total=0;", $this->table);
     return $this->pdo->query($sql);
 }
Exemplo n.º 22
0
<?php

$username = htmlentities($_POST["username"]);
$password = htmlentities($_POST["password"]);
$returnValue = array();
if (empty($username) || empty($password)) {
    $returnValue["status"] = "error";
    $returnValue["message"] = "Missing required field";
    echo json_encode($returnValue);
    return;
}
$secure_password = md5($password);
try {
    $conn = new pdo('mysql:unix_socket=/cloudsql/caramel-howl-113305:snatch;dbname=snatch', 'root', '');
} catch (PDOException $ex) {
    die(json_encode(array('status' => 'error', 'message' => 'Unable to connect')));
}
$returnValue = array();
$sql = "select count(*) from users where username='******' and password='******'";
$result = $conn->query($sql);
if ($result->fetchColumn() == 1) {
    $returnValue["status"] = "Success";
    $returnValue["message"] = "User is registered";
    echo json_encode($returnValue);
} else {
    $returnValue["status"] = "error";
    $returnValue["message"] = "User is not found";
    echo json_encode($returnValue);
}
$conn = null;
Exemplo n.º 23
0
 public function query($sql)
 {
     if ($this->path_log_file) {
         file_put_contents($this->path_log_file, $sql . "\n\n", FILE_APPEND);
     }
     ++$this->querycount;
     return parent::query($sql);
 }
Exemplo n.º 24
0
    try {
        $conn = new pdo('mysql:unix_socket=/cloudsql/caramel-howl-113305:snatch;dbname=snatch', 'root', '');
    } catch (PDOException $ex) {
        die(json_encode(array('outcome' => false, 'message' => 'Unable to connect')));
    }
} else {
    // Connect from a development environment.
    //$conn = new mysqli("173.194.235.192", "joseph", "admin", "snatch");
    try {
        $conn = new pdo('mysql:host=173.194.235.192;dbname=snatch', 'joseph', 'admin');
    } catch (PDOException $ex) {
        die(json_encode(array('outcome' => false, 'message' => 'Unable to connect')));
    }
}
echo "<table style='width:25%'><tr><td>Username</td><td>Highscore</td></tr>";
foreach ($conn->query('SELECT * from users') as $row) {
    echo "<tr><td>" . $row["username"] . "</td><td>" . $row["highscore"] . "</td></tr>";
}
$conn = null;
/*if (mysqli_connect_errno()) {
    	echo new Exception("Could not establish connection with database");
    }

    $sql = "select username, highscore from users";

    if ($result->num_rows >0) {
		//output data of each row
		while($row = $result->fetch_assoc()) {
			echo $row["username"] . " " . $row["highscore"] . "<br>";
		}
	} else {
Exemplo n.º 25
0
 * Created by PhpStorm.
 * User: niwa
 * Date: 2014/09/16
 * Time: 11:35
 */
echo "creating dummy data.\n";
$ip = '127.0.0.1';
$port = '3306';
$user = '******';
$pass = '';
$info = sprintf("mysql:host=%s;port=%s,database=;", $ip, $port);
$db = new pdo($info, $user, $pass, array(PDO::ATTR_PERSISTENT => true, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$db->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
require_once __DIR__ . '/dummy_str.php';
$db->query('use question_form');
/*名前を振る準備*/
$sth = $db->prepare('select * from memo');
$memos = array();
$sth->execute();
while ($line = $sth->fetch()) {
    $line['params'] = array();
    $memos[$line['memocd']] = $line;
}
$sth->closeCursor();
$sth = $db->prepare('select * from memo_param');
$sth->execute();
while ($line = $sth->fetch()) {
    $memos[$line['memocd']]['params'][] = $line;
}
$sth->closeCursor();
Exemplo n.º 26
0
<?php

include dirname(__FILE__) . '/dblink.php';
$pdo = new pdo("mysql:host={$localhost};port={$port};dbname={$tkdb}", "{$root}", "{$pawss}");
$pdo->query("set names 'utf8'");
date_default_timezone_set('PRC');
include dirname(__FILE__) . '../../dao/dbconfig.php';
include 'rFunction.php';
function __autoload($class_name)
{
    $class_name = ucfirst($class_name);
    $file = dirname(__FILE__) . '/../dao/' . $class_name . '.php';
    if ($class_name != '') {
        require_once $file;
    }
}
$res = rGetSiteConfig();
$paramsSiteUrl = $res['siteUrl'];
$paramswangwang = $res['wangwang'];
$paramsBangpai = $res['bangpai'];
$appkey = $res['appkey'];
$secretKey = $res['secretKey'];
$paramsPid = $res['pid'];
$paramsLogo = $res['logo'];
$paramsTitleLimit = $res['title_limit'];
$paramssiteNameaa = $res['siteName'];
$paramsUserName = '******';
include_once 'cly_common.inc.php';