- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一些旧代码使用 Perl 中的旧 Mysql
库。
大多数情况下更新代码以使用 DBD::mysql
而不是没有问题,但是我遇到了 ->numrows
不起作用的问题。
我应该怎么做才能在使用 DBD::mysql
时获得相同的功能
使用Mysql
use Mysql;
$type = "yellow";
$statement = "select name from customer where type = '$type'";
$sth = $dbh->query($statement);
if ($sth->numrows) {
print "Success!"; # This does work.
}
使用 DBD::mysql
use DBI;
use DBD::mysql;
$type = "yellow";
$statement = "select name from customer where type = ?";
$sth = $dbh->prepare($statement);
$sth->execute($type);
if ($sth->numrows) {
print "Success!"; # This doesn't work.
}
这是我返回的错误:
尾部/var/log/apache2/error.log
Can't locate object method "numrows" via package "DBI::st"
最佳答案
我认为你应该像下面这样使用它
if ($sth->rows)
关于mysql - 转换 ->numrows 以便在 Perl 中与 DBD::mysql 一起使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38476186/
我有一个未知数据表(一些列和行),我现在需要使用函数table. updateData() 要求列 id 存在于数据构造中,但我无法保证,因为数据是从未知来源中提取的。 有没有办法解决这个问题,或者有
我有以下代码,用于检查数据库(对于类)的约束。您正在尝试获取查询返回的行数,但我不断收到相同的错误 $count1= $ires1->numRows(MDB2_FETCHMODE_ASSOC); 错误
我试图弄清楚如何在 while 语句中执行 foreach 语句。正如您从这段代码中可以看出的,即使它选择了所有行,它也只会从表中提交 1 行。我如何让它选择每一行? 代码: $q2 = mysql_
mysqli_num_rows 有点问题。 查询旨在检查用户在数据库中是否有用户名条目,如果为真,则允许他们继续配置。 我的查询是: 问题是它一直给出错误的结果并重定向回来——我输入了 5 个结果,
所以我得到了错误: Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\xampp\ht
我试图用下一个代码(这是相关的部分)获得交叉表计数,这不起作用 我只是对使用数组有所了解,我想知道为什么这不起作用。我只得到 $count 一次,其他结果为 0... 在这种情况下,我有两种答案的交
我编写了一个函数来在输入之前检查数据库中是否有重复的名称。我尝试了三种不同的方法来捕获重复条目的行数,但行数总是返回为零。我最新的代码如下。 所以我现在已经尝试过这个,但 numrows 仍然为零,并
我在使用几个 for 循环使用 JavaScript 动态创建表时遇到一些问题。 在此示例中,numRows = 2 和 numCols = 6。 我的代码: var table = $(''); f
试图将我所有旧的 mysql_* 操作转换为新的,据我所知,改进的 PDO,但是这个查询似乎无法成功运行,我试图从表 PEOPLE,其中用户名 = $username(之前已声明 $username
我有 15 个数据集,全部包含 62 个信息点,我正在尝试对它们进行 pca 分析,第一个数据集中的每个点都对应第二个和第三个数据集中的相同点,等等。但是目前我的代码,见下文,产生超过 62 个点的平
我有一些旧代码使用 Perl 中的旧 Mysql 库。 大多数情况下更新代码以使用 DBD::mysql 而不是没有问题,但是我遇到了 ->numrows 不起作用的问题。 我应该怎么做才能在使用 D
我是一名优秀的程序员,十分优秀!