Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Database {
- private static $cont = null;
- public function __construct() {
- exit('Init function is not allowed');
- }
- public static function getCadena() {
- $ini = parse_ini_file('C:credenciales.ini', true);
- return "host='" . $ini['server']['host'] . "' port='" .
- $ini['server']['port'] . "' dbname='" . $ini['server']['database'] .
- "' user='" . $ini['server']['user'] . "' password='" . $ini['server']
- ['pass'] . "' ";
- }
- public static function connect() {
- $ini = parse_ini_file('C:credenciales.ini', true);
- if (null == self::$cont) {
- try {
- self::$cont = new PDO("pgsql:host=" . $ini['server']['host']
- . ";port=" . $ini['server']['port'] . ";" . "dbname=" .
- $ini['server']['database'], $ini['server']['user'],
- $ini['server']['pass']);
- } catch (PDOException $e) {
- die($e->getMessage());
- }
- }
- return self::$cont;
- }
- public static function disconnect() {
- self::$cont = null;
- }
- $pdo = Database::connect();
- $nombrefiltrar = strtoupper($_POST['nombreconductorfiltro']);
- $sql = " SELECT c_cedula, c_nombre, c_activo FROM conductor WHERE c_nombre LIKE '%" . $nombrefiltrar . "%'
- ORDER BY c_nombre ASC";
- foreach ($pdo->query($sql) as $row) {
- echo '<tr>';
- echo '<td>' . $row['c_cedula'] . '</td>';
- echo '<td>' . $row['c_nombre'] . '</td>';
- if ($row['c_activo'] == TRUE) {
- echo '<td> ACTIVO </td>';
- } else {
- echo '<td> INACTIVO </td>';
- }
- $conductor = "javascript:verEditarConductor(" . $row['c_cedula'] . ", '" . $row['c_nombre'] . "', " . $row['c_activo'] . ")";
- echo '<td><a href="' . $conductor . '" class="btn" style="background-color: #004D27" ><img src="png/edit.png" alt="x" title="Ver" style="background-color: #004D27" /></a>';
- echo '</tr>';
- }
- Database::disconnect();
- echo '</tbody>
- </table>';
- break;
Add Comment
Please, Sign In to add comment