简体   繁体   中英

What is Perl DBI difference between with bind_columns and without it?

What is the difference between the following code in perl dbi?

1.

while (my ($p1, $p2, $p3) = $sth->fetchrow_array()) {
    # ... some code ...
}

2.

$sth->bind_columns(\my ($p1, $p2, $p3));
while ($sth->fetch) {
    # ... some code ...
}

Both leads to the same result. Perlmonks advise on bind variant. I would appreciate if someone explain why.

the docs says, that binding is more efficient way to fetch data:

The binding is performed at a low level using Perl aliasing. Whenever a row is fetched from the database $var_to_bind appears to be automatically updated simply because it now refers to the same memory location as the corresponding column value. This makes using bound variables very efficient.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM