<?php
class contacts
{
public $name;
public $cno;
public $clocation;
public function __construct($name,$cno,$clocation)
{
$this->name = trim($name);
$this->cno = trim($cno);
$this->clocation= trim($clocation);
}
public function getName()
{
return $this->name;
}
public function getNO()
{
return $this->cno;
}
public function getLocation()
{
return $this->clocation;
}
}
class DataBaseAction extends contacts
{
private $db_info;
private $db_user;
private $db_pass;
private $db;
private $stmt;
public function __construct()
{
$this->db_info ='mysql:host=localhost;dbname=finalproject';
$this->db_user ='root';
$this->db_pass ='mrhot';
}
public function insert_contact($sql)
{
$this->db = new PDO($this->db_info, $this->db_user, $this->db_pass);
$this->stmt= $this->db->prepare($sql);
$this->stmt->execute(array($this->getName(),$this->getNO(),$this->getLocation()));
$this->stmt->closeCursor();
}
}
$obj = new DataBaseAction();
$l=$obj->getName();
var_dump($l);
kiLLer.zoh_1 0 Light Poster
diafol
pritaeas 2,194 ¯\_(ツ)_/¯ Moderator Featured Poster
diafol
pritaeas 2,194 ¯\_(ツ)_/¯ Moderator Featured Poster
iamthwee
diafol
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.