2017 © Pedro Pelรกez
 

library mysqlilib

Simple MySQLi Library

image

jonathanbak/mysqlilib

Simple MySQLi Library

  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 16 % Grown

The README.md

MySQLiLib

๊ฐ€๋ณ๊ฒŒ, ๊ฐ„๋‹จํžˆ ์‹ค๋ฌด์— ์ ์šฉํ• ์ˆ˜ ์žˆ๋Š” MySQL ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ์ž…๋‹ˆ๋‹ค., (*1)

์‚ฌ์šฉํ•ด๋ณด์‹œ๊ณ  ์ด์ƒ์žˆ์œผ๋ฉด ๋ฉ”์ผ์ฃผ์„ธ์š”~ ์–ธ์ œ๋“ ์ง€ ๋ฌธ์˜ ํ™˜์˜์ž…๋‹ˆ๋‹ค., (*2)

php5.6 ~ php8.2 ๊นŒ์ง€ ์‚ฌ์šฉ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค., (*3)

Install

$ composer require jonathanbak/mysqlilib

$ composer install

Test

phpunit.xml.dist ์— ์•„๋ž˜ ๋‚ด์šฉ์„ ๋ณธ์ธ์˜ MySQL ์„œ๋ฒ„ ์ •๋ณด๋ฅผ ๋„ฃ๊ณ , (*4)

<php>
    <var name="DB_HOST" value="localhost" />
    <var name="DB_USER" value="test" />
    <var name="DB_PASSWD" value="test1234" />
    <var name="DB_NAME" value="db_test" />
    <var name="DB_PORT" value="3306" />
</php>

phpunit ์‹คํ–‰ํ•˜์—ฌ ํ…Œ์ŠคํŠธ ํ•ด๋ด…๋‹ˆ๋‹ค., (*5)

$ vendor/bin/phpunit

Usage

๊ฐ„๋‹จํ•œ ๋””๋น„ ์—ฐ๊ฒฐ ๋ฐ SELECT ์ฟผ๋ฆฌ :, (*6)

$DB = new MySQLiLib($host, $user, $password, $dbName);
$query = "SELECT * FROM test";
$row = $DB->fetch($query);
var_dump($row);

SELECT

test ํ…Œ์ด๋ธ”์˜ id = 222 ์ธ ๋ฐ์ดํ„ฐ ํ•œ ํ–‰ ๊ฐ€์ ธ์˜ค๊ธฐ, (*7)

$query = "SELECT * FROM test WHERE id = ?";
$row = $DB->fetch($query, array(222));
var_dump($row);

test ํ…Œ์ด๋ธ”์˜ id = 11 ์ธ ๋ฐ์ดํ„ฐ ์—ฌ๋Ÿฌ ํ–‰ ๊ฐ€์ ธ์˜ค๊ธฐ, (*8)

$query = "SELECT * FROM test WHERE id = ?";
$rows = array();
while($row = $DB->fetch($query, array(11))){
    $rows[] = $row;
}
var_dump($rows);

test ํ…Œ์ด๋ธ”์˜ name LIKE 'ํ…Œ์ŠคํŠธ%' ์ธ ๋ฐ์ดํ„ฐ ์—ฌ๋Ÿฌ ํ–‰ ๊ฐ€์ ธ์˜ค๊ธฐ, (*9)

$query = "SELECT * FROM test WHERE name LIKE '??%'";
$rows = array();
while($row = $DB->fetch($query, array('ํ…Œ์ŠคํŠธ'))){
    $rows[] = $row;
}
var_dump($rows);

INSERT, UPDATE, DELETE

$query = "INSERT INTO test SET id = ?, reg_date = ?";
$result = $DB->query($query, array(33, date("Y-m-d H:i:s")));
var_dump($result);

$query = "DELETE FROM test SET id = ?";
$result = $DB->query($query, array(33));
var_dump($result);

Exception

test ํ…Œ์ด๋ธ”์˜ id = 33 ์ธ ๋ฐ์ดํ„ฐ๊ฐ€ ์ด๋ฏธ ์ž…๋ ฅ๋˜์žˆ์„๋•Œ Duplicate entry '33' for key 'PRIMARY' ์˜ค๋ฅ˜ ๋ฐœ์ƒ์‹œ, (*10)

try{
    $query = "INSERT INTO test SET id = ?, reg_date = ?";
    $result = $DB->query($query, array(33, date("Y-m-d H:i:s")));
}catch(\MySQLiLib\Exception $e){
    //print error message "Duplicate entry '33' for key 'PRIMARY'"
    var_dump($e->getMessage());
}

Prepared statement query

$query = "INSERT INTO test SET id = ?, reg_date = ?";
$DB->bind_param('i');
$result = $DB->query($query, array(33, date("Y-m-d H:i:s")));
var_dump($result);

$query = "DELETE FROM test SET id = ?";
$DB->bind_param('i');
$result = $DB->query($query, array(33));
var_dump($result);

The Versions

14/05 2018

dev-master

9999999-dev http://github.com/jonathanbak/MySQLiLib

Simple MySQLi Library

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

mysqli mysqli library simple db library simple dao

14/05 2018

v1.2.1

1.2.1.0 http://github.com/jonathanbak/MySQLiLib

Simple MySQLi Library

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

mysqli mysqli library simple db library simple dao

26/04 2018

v1.2

1.2.0.0 http://github.com/jonathanbak/MySQLiLib

Simple MySQLi Library

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

mysqli mysqli library simple db library simple dao

19/12 2017

v1.1

1.1.0.0 http://github.com/jonathanbak/MySQLiLib

Simple MySQLi Library

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

mysqli mysqli library simple db library simple dao

31/01 2017

v1.0

1.0.0.0 http://github.com/jonathanbak/MySQLiLib

Simple MySQLi Library

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

mysqli mysqli library simple db library simple dao