Skip to content

zavg/Zend_ORM

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

 ORM generator for Zend Framework
 Generates ZF ORM file structure from SQL script
 Author: zavg
 Version: 0.1
 Date: 02.07.2011

 Be careful, the current version of ORM code generator is extremely sensitive to the SQL formatof input file even to the tabs and space quantinty. It is actually the greatest weakness of the current code revision which should be fixed as soon as possible.
 To try the code use User.sql file with the sample input data which also exists in repository. Use this file format as the strict pattern to your input data. 

 Also to start working with ORM you should copy manually php-files with parent classes to your project form /parents directory. 

 Using examples
  
 Below there are several code snippets with examples of how the typical CRUD-operations are performed using ORM classes generated by script.

 Create:
 
$userMapper = new General_Model_UserMapper();
$user = new General_Model_User();
$data = array(
    'Login' => 'zavg',
    'Email' => 'username@somehost.com',
    'Name' => 'zavg',
    'Password' => md5("123456")
);
$user->setOptions($data);
$idUser = $userMapper->save($user);

  Update:

$userMapper = new General_Model_UserMapper();
$user = new General_Model_User();
$data = array(
    'idUser' => $idUser,
    'Name' => 'ZAVG'
);
$user->setOptions($data);
$userMapper->save($user);

  Read:

$idUser = 2;
$userMapper = new General_Model_UserMapper();
$user = $userMapper->find($idUser);

  Fetch all:

$userMapper = new General_Model_UserMapper();
$users = $userMapper->fetchAll();

  Delete:

Copy Source | Copy HTML
$idUser = 2;
$userMapper = new General_Model_UserMapper();
$userMapper->deleteObject($idUser);

Releases

No releases published

Packages

No packages published