当前位置: 首页>>代码示例>>PHP>>正文


PHP pdo::query方法代码示例

本文整理汇总了PHP中pdo::query方法的典型用法代码示例。如果您正苦于以下问题:PHP pdo::query方法的具体用法?PHP pdo::query怎么用?PHP pdo::query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pdo的用法示例。


在下文中一共展示了pdo::query方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getCountReadedMessages

    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'];
    }
开发者ID:xop32,项目名称:phpPM,代码行数:8,代码来源:MSGBox.php

示例2: gc

 /**
 * 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;
 }
开发者ID:roiKosmic,项目名称:chiconServer,代码行数:18,代码来源:MySqlSession.class.php

示例3: getAll

 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;
 }
开发者ID:Thomasvc1,项目名称:Eindtest-php,代码行数:13,代码来源:klantdao.class.php

示例4: getAll

 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;
 }
开发者ID:Thomasvc1,项目名称:Eindtest-php,代码行数:13,代码来源:extradao.class.php

示例5: restoreMysql

 /**
  * 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');
     }
 }
开发者ID:teicorp2,项目名称:APF,代码行数:26,代码来源:BackupMysql.php

示例6: pdo

<?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;
开发者ID:HoustonGiles,项目名称:bovinetracker,代码行数:16,代码来源:db.php

示例7: pdo

<?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');
开发者ID:badlamer,项目名称:hhvm,代码行数:13,代码来源:pdo_sqlite_transaction.php

示例8: sprintf

<?php

echo "this is a database test.";
$ip = '192.168.33.61';
$port = '3306';
$user = 'root';
$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;
开发者ID:niwakazuki,项目名称:shop_cart,代码行数:18,代码来源:pdo.php

示例9: sprintf

/**
 * 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 = 'root';
$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()) {
开发者ID:niwakazuki,项目名称:shop_cart,代码行数:31,代码来源:shop_cart_try.php

示例10: pdo

				<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">
			
开发者ID:NicolaCoppola,项目名称:Xbmc-Web-Skin,代码行数:30,代码来源:canali.php

示例11: pdo

<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>";
}
开发者ID:ChristyNova,项目名称:CSCI-3287-Project,代码行数:31,代码来源:available.php

示例12: pdo

</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 【批发价】
开发者ID:bubujie,项目名称:bubujie,代码行数:31,代码来源:csv.php

示例13: pdo

<?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');
开发者ID:badlamer,项目名称:hhvm,代码行数:10,代码来源:pdo_sqlite_lastinsertid.php

示例14: pdo

<?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');
开发者ID:badlamer,项目名称:hhvm,代码行数:13,代码来源:pdo_sqlite_createfunction.php

示例15: pdo

<?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});
开发者ID:badlamer,项目名称:hhvm,代码行数:8,代码来源:bug44327_3.php


注:本文中的pdo::query方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。