php - Propel 1 中按 NULL 排序

标签 php mysql propel

如何将 ORDER BY columnName IS NULL DESC, columnName DESC 添加到 Propel 查询中。我也有同样的问题as in this question但我似乎无法使用 Propel 方法找到合适的解决方案。由于该子句将嵌入到相当复杂的查询构建过程中,因此我不想只转向纯 SQL。

最佳答案

如果您使用 ModelCriteria 您可以尝试:

$query = YourEntityQuery::create('e')
    ->withColumn('e.sortColumn IS NULL', 'isSortColumnNull')
    ->orderBy('isSortColumnNull', 'desc')
    ->orderBy('e.sortColumn', 'desc');

关于php - Propel 1 中按 NULL 排序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44942895/

相关文章:

PHP注解库

javascript - 用 Instagram 图片替换 Google map 标记

php - 如何在普通主机账户上安装 Propel?

symfony - 用于继承对象的 Twig instanceof

javascript - 如果 javascript 返回 true 则重定向到 href

php - 是否可以在 php 中实例化一个函数?

PHP tot MySQL 图片上传不工作

PHP 数据库未使用正确的值进行更新

mysql - 在MySQL中使用内连接和having更新表

php - 在 Propel 中使用 EAV 模型