PHP code example of blainesch / li3_fake_model

1. Go to this page and download the library: Download blainesch/li3_fake_model library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

blainesch / li3_fake_model example snippets


class Posts extends Model {

  public $hasMany = array(
    'Comments' => array(
      'to'        => 'Comments',  // The model
      'key'       => array('_id' => 'comment_id'), // or, you can use an array of foreign keys, e.g. array('comment_ids' => '_id')
      'fieldName' => 'comments',  // The key it's on
      // `order`, `limit`, `conditions` can also be used
    ),
  );

}

$posts = Posts::all(array(
  'with' => array('Comments')
));

$posts = Posts::all(array(
  'with' => array(
    'comments' => array(
      'order' => array('date' => 'asc'),
      'limit' => 10,
      'conditions' => array(
        'flagged' => false,
      ),
    ),
));

$posts = Posts::all(array(
  'with' => array(
    'Comments' => array('Author')
  )
));