Apify allows you to perform some basic CRUD (create, read, update and delete) operations.
Create
To create a domain class use the new operator, set its properties and call save:
$user = new User(array(
    'name'  => 'James',
    'email' => 'james@gmail.com'
));
// returns the user id or false
$id = $this->getModel('User')->save($user);
The save method will persist your class to the database using the underlying database layer.
Read
Retrieve a specific user:
// returns a new instance of User
$user = $model->find(1); 
// or...
$user = $model->findBy(array(
    'email' => 'james@gmail.com', 
    'name'  => 'James'
));
Retrieve a list of users:
// returns a collection of anonymous objects
$users = $model->findAll();
$users = $model->findAllBy(array('name'=>'James'));
$options = array(
    'sort'  => 'name', 
    'order' => 'ASC'
);
$users = $model->findAllBy(array('name'=>'James'), $options));
Paginate list:
$options = array(
    'page'  => 1,
    'count' => 20,
);
$users = $model->findAll($options);
$pages = $model->paginate($options);
Pages object structure:
Object ( 
    [pagesInRange] => Array (
        [0] => 1
        [1] => 2
    ) 
    [pageCount] => 2 
    [itemCountPerPage] => 20 
    [current] => 1 
    [first] => 1 
    [last] => 2 
)
Update
To update an instance, set some properties and then simply call save again:
$user = $model->find(1); $user->name = 'Jimmy'; $model->save($user);
Delete
To delete an instance use the delete method:
$model->delete(1);
Comments
Use this form to add corrections, additions and suggestions about the documentation on this page. If you encounter any problems, please use the GitHub issue tracker.