Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implement bind_result functionality in DBI.php #14

Open
GoogleCodeExporter opened this issue Jun 3, 2015 · 3 comments
Open

implement bind_result functionality in DBI.php #14

GoogleCodeExporter opened this issue Jun 3, 2015 · 3 comments

Comments

@GoogleCodeExporter
Copy link

accept a list of values on which to bind output results (i.e.
mysqli_stmt::bind_result).

Original issue reported on code.google.com by [email protected] on 6 Oct 2008 at 12:42

@GoogleCodeExporter
Copy link
Author

[deleted comment]

@GoogleCodeExporter
Copy link
Author

Available in r300.

I can't believe I got this working.  It doesn't use the database driver's
functionality to do this (dbi doesn't let the dbdriver provide its own 
overloaded
statement handle (future feature)), but rather implements it for all dbdrivers 
by
being defined on DBIstatement.

It has received minor testing against a mysql database (although since it is
implemented for on DBIstatement, should work for all dbdrivers).

    $sth = $dbh->prepare(...);

    # variables should exist in the scope before calling bind_columns on them
    $result1 = '';
    $result2 = '';
    $result3 = '';
    ...
    $sth->bind_columns($result1, $result2, $result3, ...);

    $sth->execute(...);

    while($sth->fetch()) { # returns false when no more rows
        print "Got ($result1) = $result2\n";
    }

Note that you can call ->bind_columns multiple times and it will append to the
currently assigned list:

    $sth->bind_columns($result1);
    $sth->bind_columns($result2, $result3);

is exactly the same as above.  If you need to bind new variables to an already
existing statement, call bind_columns without any arguments to clear it out 
first.

Original comment by [email protected] on 10 Oct 2008 at 8:06

  • Added labels: Type-Enhancement
  • Removed labels: Type-Defect

@GoogleCodeExporter
Copy link
Author

Original comment by [email protected] on 10 Oct 2008 at 8:06

  • Changed state: Started

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant