macropage/mysqlihelper 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

macropage/mysqlihelper

最新稳定版本:v1.21

Composer 安装命令:

composer require macropage/mysqlihelper

包简介

A basic helper to handle mysqli connections and queries with lazy connection and auto-reconnect

README 文档

README

This is a super simple basic wrapper for mysqli, with some extras:

  • lazy connection
  • auto-reconnect
  • named-parameters

Example usage:

<?php
require 'vendor/autoload.php';

use macropage\MySQLiHelper\MySQLiBase;

$MySQLiHelper = new MySQLiBase(
	[
		'host'    => 'xxxxxxx',
		'port'    => 3306,
		'user'    => 'xxxxxx',
		'pwd'     => 'xxxxxx',
		'db'      => 'xxxxx',
		'charset' => 'utf8',
		'trace'   => true
	]
);
$newQuery = $MySQLiHelper->query('select * from table limit 0,10');
foreach ($newQuery->result as $data) {
	echo $data['table_field']."\n";
}

the defaults are:

  • charset: utf8
  • port: 3306
  • trace: true

The best: this class supports regular AND named parameters - thanks to PEAR:MDB2 where i got the code from :-)

so both works:

$MySQLiHelper->query('select * from table where a=? and b=?',[1,1]);

IS THE SAME LIKE

$MySQLiHelper->query('select * from table where a=:my_placeholder and b=:my_placeholder',['my_placeholder' => 1]);

You can call $MySQLiHelper->connect() manually, but the class uses lazy connection, so as soon as the first query is done, a connection to the mysql server will be established.

In case the connection gets lost or a first connection does not work (whyever), there is a default auto-reconnect of 5 tries with a sleep of 3 seconds. you can change this with:

$MySQLiHelper->setAutoReconnectMaxTry(x)
$MySQLiHelper->setAutoReconnectSleep(x)
$MySQLiHelper->setAutoReconnect(false)
$MySQLiHelper->setLowerTableFields(false)

You need a php developer?
Contact me via

XING
LINKEDIN
TWITTER
G+

....

统计信息

  • 总下载量: 3.68k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: AGPL-3.0-or-later
  • 更新时间: 2018-10-06

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固