joungkyun/mysql-extension-wrapper 问题修复 & 功能扩展

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

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

joungkyun/mysql-extension-wrapper

最新稳定版本:1.0.2

Composer 安装命令:

composer require joungkyun/mysql-extension-wrapper

包简介

pure PHP MySQL extension wrapper

README 文档

README

GitHub license

The mysql-wrapper api support mysql extension api, and was designed to work best as with mysql extension. If you have PHP7 environment and must need mysql extension api, this is good choise.

License

BSD 2-clause

Requirements

  1. This wrapper api requires mysqli extension on PHP 4.1 and after
  2. check with is_resource() about mysql link and mysql result, replace is_myresource() api. For example:
    <?php

    # old code
    $con = mysql_connect();
    if ( ! is_resource($con) ) {
        die ("connect failed\n");
    }

    # wrapper code
    $con = mysql_connect();
    if ( ! is_myresource($con) ) {
        die ("connect filed\n");
    }
    ?>

Example

<?php
# even if loaded mysql extension, well done.
require_once 'mysql-wrapper.php';

$con = @mysql_connect ('localhost', 'user', 'pass');
if ( ! is_myresource ($con) ) {
	trigger_error(sprintf('Connect error: %s', mysql_error()), E_USER_ERROR);
	exit;
}

mysql_select_db('mysql', $con);
mysql_set_charset ('utf8', $con);

$result = mysql_query ('SELECT * FROM user', $con);
if ( ! is_myresource($result) ) {
	trigger_error(sprintf('Query Error: %s', mysql_error()), E_USER_WARNING);
}

$rno = mysql_num_rows($result);

while ( ($row = mysql_fetch_object($result)) ) {
	printf("User: %s, Host: %s\n", $row->user, $row->host);
}

mysql_free_result($result);
mysql_close($con);

?>

Composer

first, make composer.json as follow:

{
    "require": {
        "joungkyun/mysql-extension-wrapper": "1.0.*"
    }
}

and, install mysql-extension-wrapper

[user@host project]$ php composer.phpt install
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 1 install, 0 updates, 0 removals
  - Installing joungkyun/mysql-extension-wrapper (1.0.1): Downloading (100%)
Writing lock file
Generating autoload files
[user@host project]$

and, write code as follow:

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

echo 'mysql_connect is supported ';
if ( function_exists('mysql_connect') )
    echo 'YES';
else
    echo 'NO';

echo "\n";
?>

Credits

JoungKyun.Kim

统计信息

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

GitHub 信息

  • Stars: 18
  • Watchers: 5
  • Forks: 10
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-2-Clause
  • 更新时间: 2016-08-07

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固