推进:Class 'Criteria' 未找到

Propel: Class 'Criteria' not found

我目前正在了解 Propel,但我很难让它发挥作用。
为了提供一些背景知识,我想使用 Propel 获取 table 'Message' 的最后一行。为了实现这一点,我想使用 class 'Criteria'.
我的问题是当我执行程序时 PHP 找不到 class 条件。我知道我必须以某种方式导入 class 但我不知道它位于何处。这是我的代码:

<?php
    session_start();
    // setup the autoloading
    require_once '/home/smalburg/propel/vendor/autoload.php';
    // setup Propel
    require_once '/home/smalburg/propel/generated-conf/config.php';


    //Get id from last row in table 
    $row = MessageQuery::create()->
    orderById(Criteria::DESC)->
    limit(1)->
    find();
?>

我已经使用 composer 安装了 Propel。
这是可能涉及到的错误消息(不要介意第 17 行我已经缩短了代码):

Fatal error: Uncaught Error: Class 'Criteria' not found in /var/www/html/propel/nachrichten_schicken.php:17 Stack trace: #0 {main} thrown in /var/www/html/propel/nachrichten_schicken.php on line 17

请帮我解决这个问题,我拒绝上床睡觉。

更新:
我确实去睡觉了。
首先,PetrHejda 的解决方案有效,但我也找到了解决我的特定问题的替代方法:
除了使用 orderById(\Propel\Runtime\ActiveQuery\Criteria::DESC)->(就像在 Petr 的解决方案中一样),我们可以直接说 orderById('desc')->,这也很好用。感谢您的帮助!

Propel 的 class Criteria 在命名空间 \Propel\Runtime\ActiveQuery.

将命名空间添加到 class 名称前

orderById(\Propel\Runtime\ActiveQuery\Criteria::DESC)

或导入它

use Propel\Runtime\ActiveQuery\Criteria;

orderById(Criteria::DESC)