GithubHelp home page GithubHelp logo

Comments (6)

copostic avatar copostic commented on June 2, 2024 1

No problem, thanks for answering !
It indeed works better thanks :)

from pdo.

copostic avatar copostic commented on June 2, 2024

I also have an error Fatal error: Uncaught PDOException: SQLSTATE[HY093]: Invalid parameter number
on this code:

$countStmt = $db->select(['count' => new Method('COUNT', 'id')])
                            ->from('game_prize_won')
                            ->where(new Conditional('creationDate', '>', date('c', strtotime('today midnight'))));

from pdo.

kwhat avatar kwhat commented on June 2, 2024

Can you try with version 2.1 and let me know if you still have this problem.

from pdo.

copostic avatar copostic commented on June 2, 2024

Can you try with version 2.1 and let me know if you still have this problem.

Yep, still have both issues..

from pdo.

copostic avatar copostic commented on June 2, 2024

So, any idea of the issue @kwhat ?

from pdo.

kwhat avatar kwhat commented on June 2, 2024

Sorry, I've been out of town for a few days and things have been a bit busy at work.

There are a couple of problems with the first select statement. The arguments for the Grouping do not require an array, the constructor should be veradic. The Conditional statements for the data will need either Raw or Method to work correctly due to the statement being prepared.

    $db->select([
        'id',
        'value',
        'text',
        'isLosing',
        '_maxWinner',
        '_maxWinnerPerPeriod',
        '_maxWinnerPeriod',
        '_minDate',
        '_maxDate',
        'totalWon',
    ])
    ->from('game_prize_types')
    ->where(
        new Grouping(
            'AND',
            new Grouping(
                'OR',
                new Conditional('totalWon', '>', '_maxWinner'),
                new Conditional('_maxWinner', 'IS', 'NULL')
            ),
            new Grouping(
                'OR',
                new Conditional('_minDate', '<=', new Raw('NOW()')),
                new Conditional('_minDate', 'IS', 'NULL')
            ),
            new Grouping(
                'OR',
                new Conditional('_maxDate', '>=', new Method('NOW')),
                new Conditional('_maxDate', 'IS', 'NULL')
            )
        )
    )

The second is a little more subtle. The issue is because you cannot prepare values for columns, so you need to use Raw instead of Method. Method was really only conceived for calling stored procedures but will also work for functions called within conditionals. I know, its a bit confusing and I am working on making it a bit more flexible with 3.x among other things.

$db->select(['count' => new Raw('COUNT(id)')])
        ->from('game_prize_won')
        ->where(new Conditional('creationDate', '>', date('c', strtotime('today midnight'))))

from pdo.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.