önce tablolarının asagidaki gibi modellerini olusturmalisin. asagida contacts tablosunu ornek verdim. kolonlari id name surname gibi. umarim aciklayici olmustur.
<?php
class Contacts
{
protected $id;
protected $name;
protected $surname;
public function setName($name) {
// kontroller
$this->name = $name;
return $this;
}
public function setSurname($surname) {
// kontroller
$this->surname = $name;
return $this;
}
public function getId()
{
return $this->id;
}
public function getName() {
return $this->name;
}
public function getSurname() {
return $this->surname;
}
public function save()
{
// mysql_query("INSERT INTO contacts(name, surname) VALUES('".$this->name."', '".$this->surname."')")
// insert edildimi kontrol
$this->id = mysql_insert_id();
}
}
$c = new Contacts();
$c->setName("hede")
->setUserName("hodo")
->save();
$eklenen_id = $c->getId();