调用未定义的方法PDOStatement :: fetch_array()

时间:2014-09-27 06:39:53

标签: php html datetime pdo timezone

我试图创建一个采用用户默认时区的系统,然后将其从服务器时区转换为该时区。这是任何用户都可以在我的网站上查看的IP日志。我完全难过......

    <?php
    $SQLGetIP = $odb -> prepare("SELECT * FROM `loginip` WHERE `username` = :username ORDER BY `loginip`.`date` DESC");
    $SQLGetIP -> execute(array(':username' => $_SESSION['username']));
        $getInfo = $SQLGetIP->fetch_array();

    $query = $odb -> prepare("SELECT * FROM `users` WHERE `id` = :id");
    $query -> execute(array(':id' => $_SESSION['id']));
        $data = $query->fetch_array();


    $dt1 = $getInfo['date'];
    $tz = $data['timezone'];
    $dt = new DateTime("@".$dt1."");
    $dt -> setTimeZone(new DateTimeZone($tz));

    $IP = $getInfo['logged'];
    $Date = $dt->format('F d, Y - h:i:s A');

        echo '<tr><td>'.$IP.'</td><td>'.$Date.'</td></tr>';

    ?>

2 个答案:

答案 0 :(得分:1)

$result = $sth->fetch(fetch_style);

fetch_style可以是:

PDO::FETCH_ASSOC

PDO::FETCH_BOTH (default)

PDO::FETCH_BOUND

PDO::FETCH_CLASS

PDO::FETCH_INTO

PDO::FETCH_LAZY

PDO::FETCH_NAMED:

PDO::FETCH_NUM

PDO::FETCH_OB

参考:http://php.net/manual/en/pdostatement.fetch.php

答案 1 :(得分:0)

不应该是:

$resultset = $query -> execute(array(':id' => $_SESSION['id']));
$data = $resultset->fetch_array();