Parameterized Query Fat Free Framework

Lonefish

I'm having troubles with constructing query's in fat free framework with more than one parameter.

    $result = $db -> exec( array('SELECT * 
        FROM table WHERE table.type = ?', ' OR table.type = ?'), array($id[0],$id[1]));

I get this error : Invalid argument supplied for foreach()

[Z:/web/SITE/lib/base.php:2015] Base->error(500,'Invalid argument supplied for foreach()')

The query works when I test it on the db directly, so that's not the issue.

And to be honest, I don't see any difference with the code shown here :

$db->exec(
    array(
        'DELETE FROM diet WHERE food=:name',
        'INSERT INTO diet (food) VALUES (?)',
        'SELECT * FROM diet'
    ),
    array(
        array(':name'=>'cola'),
        array(1=>'carrot'),
        NULL
    )
);

EDIT Various options that don't work :

$result = $db -> exec( array('SELECT * 
            FROM table WHERE table.type = ? OR table.type = ?'), array($id[0],$id[1]));

$result = $db -> exec( array('SELECT * 
            FROM table WHERE table.type = ?', ' OR table.type = ?' ,$id[0],$id[1]);

This is the example from Fat free framework itself.. Any help is appreciated..

ikkez

It should be

$result = $db -> exec(
  'SELECT * FROM table WHERE table.type = ? OR table.type = ?', 
  array(1=>$id[0],2=>$id[1])
);

When the first parameter is an array, it'll transform into a transaction where each array value from $commands and $args is used for a single query. http://fatfreeframework.com/sql#Transaction

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Parameterized Query Fat Free Framework

From Dev

fat free framework find and cast

From Dev

Fat Free framework not updating record

From Dev

Fat Free Framework configurations on a subdomain

From Dev

Fat-Free framework with Smart

From Dev

Fat-Free-Framework global variables and functions

From Dev

How to use Flash messages in fat free framework?

From Dev

Catch uploaded file name in Fat Free Framework

From Dev

Catch uploaded file name in Fat Free Framework

From Dev

Using variables in fat-free framework template

From Dev

Fat Free framework dynamic routing does not work

From Dev

adhoc virtual fields fat-free-framework

From Dev

Fat Free Framework dynamic cache expiration

From Dev

Site Navigation Controller in Fat Free Framework

From Dev

Fat-Free framework : the F3 Autoloader

From Dev

Why session message is not working Fat-free-framework?

From Dev

Getting data values from form in Fat-Free framework

From Dev

Fat Free Framework 3.5 conditional routes in .ini format

From Dev

Multiple domains and one session fat-free framework

From Dev

Using HTML in Fat-Free-Framework .ini files

From Dev

PHP - Fat Free Framework - Named URL Routing in Subfolder - 404

From Dev

Fat-Free Framework, Wix, and X-Frame-Options

From Dev

Fat Free Framework returns 404 error with custom routes

From Dev

Why session message is not working Fat-free-framework?

From Dev

start f3 (fat free framework) using composer

From Dev

BYTEA retrieval via Fat Free Framework SQL data mapper

From Dev

How to create server side validation in fat free framework?

From Dev

How would I use PHPExcel library in Fat-free framework?

From Dev

Easiest way to retrieve a single field from database with Fat-Free Framework?

Related Related

  1. 1

    Parameterized Query Fat Free Framework

  2. 2

    fat free framework find and cast

  3. 3

    Fat Free framework not updating record

  4. 4

    Fat Free Framework configurations on a subdomain

  5. 5

    Fat-Free framework with Smart

  6. 6

    Fat-Free-Framework global variables and functions

  7. 7

    How to use Flash messages in fat free framework?

  8. 8

    Catch uploaded file name in Fat Free Framework

  9. 9

    Catch uploaded file name in Fat Free Framework

  10. 10

    Using variables in fat-free framework template

  11. 11

    Fat Free framework dynamic routing does not work

  12. 12

    adhoc virtual fields fat-free-framework

  13. 13

    Fat Free Framework dynamic cache expiration

  14. 14

    Site Navigation Controller in Fat Free Framework

  15. 15

    Fat-Free framework : the F3 Autoloader

  16. 16

    Why session message is not working Fat-free-framework?

  17. 17

    Getting data values from form in Fat-Free framework

  18. 18

    Fat Free Framework 3.5 conditional routes in .ini format

  19. 19

    Multiple domains and one session fat-free framework

  20. 20

    Using HTML in Fat-Free-Framework .ini files

  21. 21

    PHP - Fat Free Framework - Named URL Routing in Subfolder - 404

  22. 22

    Fat-Free Framework, Wix, and X-Frame-Options

  23. 23

    Fat Free Framework returns 404 error with custom routes

  24. 24

    Why session message is not working Fat-free-framework?

  25. 25

    start f3 (fat free framework) using composer

  26. 26

    BYTEA retrieval via Fat Free Framework SQL data mapper

  27. 27

    How to create server side validation in fat free framework?

  28. 28

    How would I use PHPExcel library in Fat-free framework?

  29. 29

    Easiest way to retrieve a single field from database with Fat-Free Framework?

HotTag

Archive