ou algume poderia me indicar um que tamb tenha as msm funcçoes tipo para exibir o codigo assim
<?php
if($teste = 5)
{}
?>
Male
flavianog hasn't added any friends yet.
03/08/2010, 16:36
<?php
if($teste = 5)
{}
?>
03/07/2010, 17:03
<?php
class conexao{
private $host;
private $dbName;
private $user;
private $pass;
private $bd;
public function conexao($host,$dbName,$user,$pass){
$this->host = $host;
$this->dbName =$dbName;
$this->user = $user;
$this->pass = $pass;
$this->conectar();
}
function conectar(){
$dsn = 'mysql:host='.$this->host.';dbname='.$this->dbName;
try {
$this->bd = new PDO($dsn,$this->user,$this->pass);
$this->bd->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);
} catch (PDOException $e) {
print "Houve um erro com a conexão ao banco de dados <br/> ".$e->getMessage();
}
}
function inserir($array){
$ax = 0;
foreach($array as $auxCampoBd => $vlr){
if($ax == 0){
$campoBd .= $auxCampoBd;
$campoBd2 .= ":".$auxCampoBd;
$ax = 1;
}
else{
$campoBd .= ",".$auxCampoBd;
$campoBd2 .= ",:".$auxCampoBd;
}
}
$sql = ' INSERT INTO usuario('.$campoBd.') VALUES ('.$campoBd2.') ';
try {
$query = $this->bd->prepare($sql);
foreach($array as $auxcampo => $auxValor){
$query->bindValue(':'.$auxcampo,$auxValor,PDO::PARAM_STR);
}
$query->execute();
}catch (PDOException $e) {
echo $e->getMessage();
}
}
}
?>
acesso.php
<?php
include_once 'class.conexao.php';
define("HOST","localhost");
define("DBNAME","testar");
define("USER","root");
define("PASS","123456");
$conexao = new conexao(HOST,DBNAME,USER,PASS);
$conexao->inserir(array('nome' => 'Flaviano','sobrenome' =>'da Silva','email' => 'flaviano@yahoo.com.br'));
?>
Community Forum Software by IP.Board
Licensed to: Webmasters Online

Postagens