在 DBD::CSV 中,f_ext 属性中的 /r 是什么意思?
为什么只有第二个示例将扩展名附加到文件名以及“.csv/r”中的“/r”的用途。
#!/usr/bin/env perl
use warnings; use strict;
use 5.012;
use DBI;
my $dbh = DBI->connect( "DBI:CSV:f_dir=/home/mm", { RaiseError => 1, f_ext => ".csv/r"} );
my $table = 'new_1';
$dbh->do( "DROP TABLE IF EXISTS $table" );
$dbh->do( "CREATE TABLE $table ( id INT, name CHAR, city CHAR )" );
my $sth_new = $dbh->prepare( "INSERT INTO $table( id, name, city ) VALUES ( ?, ?, ?, )" );
$sth_new->execute( 1, 'Smith', 'Greenville' );
$dbh->disconnect();
# --------------------------------------------------------
$dbh = DBI->connect( "DBI:CSV:f_dir=/home/mm", { RaiseError => 1 } );
$dbh->{f_ext} = ".csv/r";
$table = 'new_2';
$dbh->do( "DROP TABLE IF EXISTS $table" );
$dbh->do( "CREATE TABLE $table ( id INT, name CHAR, city CHAR )" );
$sth_new = $dbh->prepare( "INSERT INTO $table( id, name, city ) VALUES ( ?, ?, ?, )" );
$sth_new->execute( 1, 'Smith', 'Greenville' );
$dbh->disconnect();
Why does only the second example append the extension to the filename and what is the "/r" in ".csv/r" for.
#!/usr/bin/env perl
use warnings; use strict;
use 5.012;
use DBI;
my $dbh = DBI->connect( "DBI:CSV:f_dir=/home/mm", { RaiseError => 1, f_ext => ".csv/r"} );
my $table = 'new_1';
$dbh->do( "DROP TABLE IF EXISTS $table" );
$dbh->do( "CREATE TABLE $table ( id INT, name CHAR, city CHAR )" );
my $sth_new = $dbh->prepare( "INSERT INTO $table( id, name, city ) VALUES ( ?, ?, ?, )" );
$sth_new->execute( 1, 'Smith', 'Greenville' );
$dbh->disconnect();
# --------------------------------------------------------
$dbh = DBI->connect( "DBI:CSV:f_dir=/home/mm", { RaiseError => 1 } );
$dbh->{f_ext} = ".csv/r";
$table = 'new_2';
$dbh->do( "DROP TABLE IF EXISTS $table" );
$dbh->do( "CREATE TABLE $table ( id INT, name CHAR, city CHAR )" );
$sth_new = $dbh->prepare( "INSERT INTO $table( id, name, city ) VALUES ( ?, ?, ?, )" );
$sth_new->execute( 1, 'Smith', 'Greenville' );
$dbh->disconnect();
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
它强制要求扩展(而不是可选的)。它来自
DBD::File< /code>
(
DBD::CSV
的基类):It forces the extension to be required (rather than optional). It comes from
DBD::File
(a base class forDBD::CSV
):我忘记了 2. 和 3. 参数的占位符;现在第一个例子也有效了。
I've forgotten placeholders for the 2. and 3. argument; now the first example works too.