Nemogu da skontam potrebu kao npr doctrine sto radi.
Sve to sto doctrine nudi to nudi moze se uraditi i u zend fw i ci fw ali samo sto nije ORM. Zasto mora da je orm i zasto ga toliko forsiraju na elance? Nije mi jasno.
Resio sam da krenem sa doctrine ali nekontam zasto bi radio nesto sto zahteva vise kodiranja i vise vremena. U zend i CI FW jednostavno napravim samo model npr sa metodama getAllUser(), addUser(), deleteUser() itd... i povezem sa controllerom i to je ceo posao. Dok u doktrine pravim model pa pravim yml i plus koliko vidim da u doctrine modeli su potpuno drugaciji.
Ci model npr
class User extends CI_Model {
public function __construct() {
parent::__construct();
}
public function getAllUser() {
$query = $this->db->query("SELECT * FROM user");
if($query->num_rows() > 0 ){
return $query->result();
}
}
}
Dok doctrine zahteva da definisem sve kolone u tabeli
abstract class BaseUser extends Doctrine_Record
{
public function setTableDefinition()
{
$this->setTableName('user');
$this->hasColumn(
'id', 'integer', 8,
array(
'type' => 'integer',
'length' => 8,
'primary' => true,
'autoincrement' => true
)
);
$this->hasColumn(
'first_name', 'string', 255,
array(
'type' => 'string',
'length' => 255
)
);
$this->hasColumn(
'last_name', 'string', 255,
array(
'type' => 'string',
'length' => 255
)
);
}
}
Pa posle YML
User:
tableName: user
columns:
id:
type: integer(8)
primary: true
autoincrement: true
is_active:
type: integer(1)
default: '1'
is_super_admin:
type: integer(1)
default: '0'
created_at:
type: timestamp(25)
notnull: true
updated_at:
type: timestamp(25)
notnull: true
first_name: string(255)
last_name: string(255)
username: string(255)
password: string(255)
type: string(255)
Ovo je previse koda za jednu operaciju bar po meni.
U cemu je razlika zasto ga toliko forsiraju sve ovo uradim na mnogo laksi i elegantniji nacin. Citao sam wiki o orm-u sve je to ok ali i dalje nekapiram...
Hvala.