Overview

Namespaces

  • Charcoal
    • Loader
    • Model
      • Service
      • ServiceProvider
    • Source
      • Database
    • Validator

Classes

  • Charcoal\Loader\CollectionLoader
  • Charcoal\Loader\FileLoader
  • Charcoal\Model\AbstractMetadata
  • Charcoal\Model\AbstractModel
  • Charcoal\Model\Collection
  • Charcoal\Model\Model
  • Charcoal\Model\ModelMetadata
  • Charcoal\Model\ModelValidator
  • Charcoal\Model\Service\MetadataLoader
  • Charcoal\Model\Service\ModelBuilder
  • Charcoal\Model\Service\ModelLoader
  • Charcoal\Model\Service\ModelLoaderBuilder
  • Charcoal\Model\ServiceProvider\ModelServiceProvider
  • Charcoal\Source\AbstractSource
  • Charcoal\Source\Database\DatabaseFilter
  • Charcoal\Source\Database\DatabaseOrder
  • Charcoal\Source\Database\DatabasePagination
  • Charcoal\Source\DatabaseSource
  • Charcoal\Source\DatabaseSourceConfig
  • Charcoal\Source\Filter
  • Charcoal\Source\Order
  • Charcoal\Source\Pagination
  • Charcoal\Source\SourceConfig
  • Charcoal\Validator\AbstractValidator
  • Charcoal\Validator\ValidatorResult

Interfaces

  • Charcoal\Model\CollectionInterface
  • Charcoal\Model\DescribableInterface
  • Charcoal\Model\MetadataInterface
  • Charcoal\Model\ModelInterface
  • Charcoal\Source\DatabaseSourceInterface
  • Charcoal\Source\FilterInterface
  • Charcoal\Source\OrderInterface
  • Charcoal\Source\PaginationInterface
  • Charcoal\Source\SourceInterface
  • Charcoal\Source\StorableInterface
  • Charcoal\Validator\ValidatableInterface
  • Charcoal\Validator\ValidatorInterface

Traits

  • Charcoal\Model\DescribableTrait
  • Charcoal\Source\StorableTrait
  • Charcoal\Validator\ValidatableTrait
  • Overview
  • Namespace
  • Class
 1: <?php
 2: 
 3: namespace Charcoal\Source\Database;
 4: 
 5: // Local parent namespace dependencies
 6: use \Charcoal\Source\Pagination;
 7: 
 8: /**
 9:  * The DatabasePagination makes a Pagination SQL-aware
10:  */
11: class DatabasePagination extends Pagination
12: {
13:     /**
14:      * Get the pagination's SQL string (Full "LIMIT" subquery)
15:      *
16:      * For example, for the pagination `{page:3,num_per_page:50}` the result
17:      * would be: `' LIMIT 100, 50'`.
18:      *
19:      * @return string
20:      */
21:     public function sql()
22:     {
23:         $sql = '';
24:         $page = $this->page() ? $this->page() : 1;
25:         $numPerPage = $this->numPerPage();
26: 
27:         if ($numPerPage) {
28:             $first_page = max(0, (($page-1)*$numPerPage));
29:             $sql = ' LIMIT '.$first_page.', '.$numPerPage;
30:         }
31:         return $sql;
32:     }
33: }
34: 
API documentation generated by ApiGen