Results 1 to 5 of 5

Thread: [RESOLVED] correct way to bind many columns on PDO

Threaded View

  1. #1
    Join Date
    May 2006

    resolved [RESOLVED] correct way to bind many columns on PDO

    I'm trying to learn how to work with PDO queries and I'm selecting a series of columns from a table with the intention of looping through them. I'm binding each column to a variable like this:

    PHP Code:
        $stmt $db -> prepare("SELECT value1, value2, value3, value4, value5, value6, value7, value8, value9, value10 from table"); 
    $stmt -> execute();
    $stmt -> bindColumn(1$value1);
    $stmt -> bindColumn(2$value2);
    $stmt -> bindColumn(3$value3);
    $stmt -> bindColumn(4$value4);
    $stmt -> bindColumn(5$value5);
    $stmt -> bindColumn(6$value6);
    $stmt -> bindColumn(7$value7);
    $stmt -> bindColumn(8$value8);
    $stmt -> bindColumn(9$value9);
    $stmt -> bindColumn(10$value10);
    $stmt -> bindColumn(11$value11);
    $stmt -> bindColumn(12$value12); 
    This hardly seems like the proper way to do this however. I could make a loop that binds every value to a variable with the name of the column, but I was wondering if there's something closer to this method I used with MySQLi:

    PHP Code:
    $stmt -> bind_result($value1$value2$value3$value4$value5$value6$value7$value8$value9$value10); 
    Last edited by Iceline; 01-22-2014 at 06:00 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center