Skip to content

Commit

Permalink
Merge pull request #2 from emalherbi/nova-versao
Browse files Browse the repository at this point in the history
Nova versao
  • Loading branch information
emalherbi authored May 3, 2021
2 parents 6335400 + 0ce778e commit 884b123
Show file tree
Hide file tree
Showing 5 changed files with 167 additions and 173 deletions.
41 changes: 17 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ composer require emalherbi/mymysql
require_once 'vendor/autoload.php';

try {
if (@date_default_timezone_get() !== @ini_get('date.timezone')) {
@date_default_timezone_set('America/Sao_Paulo');
}

$mysql = new MyMysql\MyMysql(array(
'DB_LOG' => true,
'DB_HOST' => '192.168.1.100',
Expand All @@ -28,65 +24,63 @@ try {

/* fetch */

$result = $mysql->fetchRow('ENTIDADES', array('ID_ENTIDADE' => '2'), 'ORDER BY ID_ENTIDADE');
$result = $mysql->fetchRow('CLIENTS', array('ID_CLIENTS' => '2'), 'ORDER BY ID_CLIENTS');
echo '<pre>';
echo print_r($result);
echo '</pre>';

$result = $mysql->fetchRow2('SELECT * FROM ENTIDADES');
$result = $mysql->fetchRow2('SELECT * FROM CLIENTS');
echo '<pre>';
echo print_r($result);
echo '</pre>';

$result = $mysql->fetchAll('ENTIDADES', array('ID_ENTIDADE' => '2'), 'ORDER BY ID_ENTIDADE');
$result = $mysql->fetchAll('CLIENTS', array('ID_CLIENTS' => '2'), 'ORDER BY ID_CLIENTS');
echo '<pre>';
echo print_r($result);
echo '</pre>';

$result = $mysql->fetchAll2('SELECT * FROM ENTIDADES LIMIT 2');
$result = $mysql->fetchAll2('SELECT * FROM CLIENTS LIMIT 2');
echo '<pre>';
echo print_r($result);
echo '</pre>';

/* insert */

$item = new stdClass();
$item->ID_MESA = 0;
$item->ID_EMPRESA = 2;
$item->CODIGOMESA = 999;
$item->DESCRICAO = 'TESTE';
$item->ATIVO = 1;
$item->ID_BOARD = 0;
$item->CODE = 999;
$item->DESCRIPTION = 'TEST';
$item->ACTIVE = 1;

$result = $mysql->insert('MESAS', $item);
$result = $mysql->insert('BOARD', $item);
echo '<pre>';
echo print_r($result);
echo '</pre>';

/* update */

$ID_MESA = 530;
$ID_BOARD = 530;
$item = new stdClass();
$item->ID_EMPRESA = 2;
$item->CODIGOMESA = 999;
$item->DESCRICAO = 'TESTE';
$item->ATIVO = 1;
$item->CODE = 999;
$item->DESCRIPTION = 'TEST';
$item->ACTIVE = 1;

$result = $mysql->update('MESAS', $item, array('ID_MESA' => $ID_MESA), $ID_MESA);
$result = $mysql->update('BOARD', $item, array('ID_BOARD' => $ID_BOARD), $ID_BOARD);
echo '<pre>';
echo print_r($result);
echo '</pre>';

/* delete */

$ID_MESA = 531;
$result = $mysql->delete('MESAS', array('ID_MESA' => $ID_MESA));
$ID_BOARD = 531;
$result = $mysql->delete('BOARD', array('ID_BOARD' => $ID_BOARD));
echo '<pre>';
echo print_r($result);
echo '</pre>';

/* execute */

$sql = " INSERT INTO MESAS(ID_EMPRESA, CODIGOMESA, DESCRICAO) VALUES (2, 888, 'TESTE') ";
$sql = " INSERT INTO BOARD(CODE, DESCRIPTION) VALUES (888, 'TEST') ";
$result = $mysql->execute($sql);
echo '<pre>';
echo print_r($result);
Expand All @@ -97,4 +91,3 @@ try {
die(print_r($e->getMessage().'-'.$mysql->getError()));
}
```

7 changes: 7 additions & 0 deletions sql/log.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
CREATE TABLE IF NOT EXISTS `MYMYSQLLOG` (
`ID_MYMYSQLLOG` INT AUTO_INCREMENT,
`DATEHOUR` DATETIME DEFAULT CURRENT_TIMESTAMP(),
`LOG` VARCHAR(250),
`ERROR` VARCHAR(250),
CONSTRAINT PK_MYMYSQLLOG PRIMARY KEY (`ID_MYMYSQLLOG`)
)ENGINE=INNODB;
51 changes: 0 additions & 51 deletions src/INI.php

This file was deleted.

6 changes: 0 additions & 6 deletions src/MyMysql.ini

This file was deleted.

Loading

0 comments on commit 884b123

Please sign in to comment.