We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 42161
    • 42 Posts
    Hello. I'm trying to build an xPDO query (to a custom table).
    The line
    $query->where(array('price:>=' => 4));

    works fine, but when I change it to
    $query->where(array('price:>=' => 4.25));

    I get the following message in the error log:
    [2013-06-15 22:22:43] (ERROR @ /index.php) Error 21000 executing query: SELECT [...] WHERE  ( `Flat`.`status` >= ? AND `Flat`.`price` >= ? )  ORDER BY areaTotal ASC, `Flat`.`id` ASC  - Array
    (
        [0] => 21000
        [1] => 1241
        [2] => Operand should contain 1 column(s)
    )

    Question marks instead of values and an extra ORDER BY (`Flat`.`id`) in the log, while the SQL produced by
    $query->prepare();
    print $query->toSQL();
    

    prints
    ... WHERE ( `Flat`.`status` >= 1 AND `Flat`.`price` >= 4 ) ORDER BY areaTotal ASC

    with 4.25 truncated to 4.

    MODX 2.2.6
    PHP 5.2.17
    • What is the dbtype and phptype of the column in your schema?

      Could possibly be this...

      http://tracker.modx.com/issues/7452



        • 42161
        • 42 Posts
        Quote from: opengeek at Jun 16, 2013, 02:59 PM
        What is the dbtype and phptype of the column in your schema?
        <object class="Flat" table="flat" extends="xPDOSimpleObject">
            ...
            <field key="price" dbtype="decimal" precision="7,2" phptype="float" null="false" />
        </object>
        Quote from: opengeek at Jun 16, 2013, 02:59 PM
        Could possibly be this...

        http://tracker.modx.com/issues/7452
        Maybe it really has something to do with number format / locale. I'll look into that, thank you.