| 1 | <?php |
| 2 | |
| 3 | function fetch( |
| 4 | PDOStatement|false $statement, |
| 5 | $parametros = [], |
| 6 | int $mode = PDO::FETCH_ASSOC, |
| 7 | $opcional = null |
| 8 | ) { |
| 9 | |
| 10 | if ($statement === false) { |
| 11 | |
| 12 | return false; |
| 13 | } else { |
| 14 | |
| 15 | if (sizeof($parametros) > 0) { |
| 16 | $statement->execute($parametros); |
| 17 | } |
| 18 | |
| 19 | if ($opcional === null) { |
| 20 | return $statement->fetch($mode); |
| 21 | } else { |
| 22 | $statement->setFetchMode($mode, $opcional); |
| 23 | return $statement->fetch(); |
| 24 | } |
| 25 | } |
| 26 | } |
| 27 |