Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Conexion {
- function Conectar(){
- try{
- $servidor = "localhost";
- $user = "root";
- $pass = "";
- $db = "bdejemplos";
- $con = new PDO("mysql:host=$servidor;dbname=$db",$user,$pass);
- echo 'conectado';
- } catch (Exception $e){
- echo 'Error '. $e->getMessage();
- }
- return $con;
- }
- }
- ?>
- ***OpClientes.php***
- <?php
- include './Conexion.php';
- //include_once '../entidades/Clientes.php';
- class OpClientes {
- function NCodigo() {
- $con = new Conexion();
- $con->Conectar();
- //$cli = new Clientes();
- //$sql = "call bdejemplos.IdCliente(?)";
- $sql = "SELECT nom FROM `clientes where id = ?";
- $consulta = $con->prepare($sql);
- if ($consulta->execute(array('miguel'))) {
- while ($fila = $consulta->fetch()) {
- echo "$fila";
- }
- }
- }
- }
- $c = new OpClientes();
- $c->NCodigo();
- ?>
- Fatal error: Call to undefined method Conexion::prepare() in
- C:xampphtdocsejemplosModelosOpClientes.php on line 14
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement