PDO connection file. How to use?

Asked

Viewed 449 times

-5

I have a PDO connection file. To include this connection in other system files in order to make the requests in the database, I will use this????

<?php require('conexao.php'); ?>
  • 4

    Okay... now, what’s your question?

  • 4

    responding: yes..... more any information?

  • 4

    If you who know the contents of the file are in doubt, imagine us.

1 answer

3


Well, your doubt was 'half' vague for me, I mean, half is just not to say completely, but anyway...

The archive PDO that Voce must be referring to works as a classe, usually create a separate file and make only one require_once for practicality, but of course, if in any interaction with the bank, you want to open a conexão with the bank manually, it is so vc put in your code without making references

Here at the company we use 3 classes for connection to a bank...

pdo.php <-- where we make the connection, say physical;

cmd_sql.php <-- where we create classes to help us assemble the SQL;

dadosconectabanco.php <-- where we put the necessary data in the pdo.php to make the connection to the bank

In the latter it is worth mentioning that we should create one for each system, because it should contain more specific information about the bank that Voce will connect, be SQL, oracle or anyother.. type information: Porta, IP, Schema, <--[1] Tabela, Login, senha, etc, etc.

[1] - These Voces can be placed directly on PDO, many times this data is half standard

Browser other questions tagged

You are not signed in. Login or sign up in order to post.