Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class dbManager {
- // dbManager Alpha 0.0 - By: PrimoDeveloper
- // 27/01/2014
- // Public Domain
- public function readTable(string $table,array $whereVars=null) {
- # Validação
- if (!isset($table)) {return false;$cancel=true;} // Se a tabela não for indicada, cancelar.
- // Se a operação não foi cancelada
- if (!$cancel==true) {
- // Checa se usa WHERE ou não
- if (!$whereVars==null && is_array($whereVars)) {$useWhere=true;} else {$useWhere=false;} // $useWhere, indica se vai usar o WHERE ou não
- // TODO: Fazer o mesmo com outras variaveis
- # Query
- $query = "SELECT FROM $table";
- if ($useWhere==true) {
- $query.=" WHERE";
- $count=count($whereVars);
- $i=-1;
- while($i<$count-1) {
- $i++;
- if ($i==$count) {
- $query.=" ".$whereVars[$i];
- }
- else {
- $query.=" ".$whereVars[$i]." AND";
- }
- }
- }
- }
- // Fazer a conexão com BD e, PDO e outros akie
- return true;// TODO: retornar o resultado
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment