douhan1860 2016-01-22 21:34
浏览 31

如何使用namepsaced类使用PHP PDO :: FETCH_CLASS名称?

I am currently trying to update my code base to use namespacing and more if the OOP features of PHP >= 5.5.*

One of the problems I am running into is not data results using PHP's PDO lib to fetch a data model through a class object. For example:

$locations = DBO::getInstance()->query("
                SELECT " . SWLocation::COLUMNS . "
                FROM " . SWLocation::TABLE_NAME . " AS a
                WHERE a.station_id = '" . $stationId . "'
                AND (
                    a.site LIKE '%" . strval($terms) . "%'
                    OR a.frequency BETWEEN (FLOOR(" . floatval($terms) . ") + -0.5) AND (FLOOR(" . floatval($terms) . ") + 0.5)
                )
            ")->fetchAll(\PDO::FETCH_CLASS, 'Ode\DBO\SWLocation\Model');

This query is not producing any data results in PHP, but when I print the query it gives me rows of results. I am guessing that the change over to the namespaced code is what is producing a problem when I reference the full namespace path to the data model class. Am I using this correctly? If not what else should I be doing?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 对于知识的学以致用的解释
    • ¥50 三种调度算法报错 有实例
    • ¥15 关于#python#的问题,请各位专家解答!
    • ¥200 询问:python实现大地主题正反算的程序设计,有偿
    • ¥15 smptlib使用465端口发送邮件失败
    • ¥200 总是报错,能帮助用python实现程序实现高斯正反算吗?有偿
    • ¥15 对于squad数据集的基于bert模型的微调
    • ¥15 为什么我运行这个网络会出现以下报错?CRNN神经网络
    • ¥20 steam下载游戏占用内存
    • ¥15 CST保存项目时失败