十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
getMessage();
exit();
}
static::$instance->setAttribute(\PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, false);
}
public static function getInstance()
{
if (!(static::$instance instanceof \PDO)) {
new static();
}
return static::$instance;
}
public static function excuteQuery(string $sql)
{
static::$sth = static::$instance->prepare($sql);
static::$sth->execute();
}
//防止实例被克隆
private function __clone()
{
}
public static function cursor()
{
while ($row = static::$sth->fetch(\PDO::FETCH_ASSOC)) {
yield $row;
}
}
}
DB::getInstance();
DB::excuteQuery("select * from bill_info");
foreach (DB::cursor() as $info) {
echo $info['id'] . PHP_EOL;
}