PHP Classes
elePHPant
Icontem

File: phptricksORM/Operations/Cond.php

Recommend this page to a friend!
  Classes of mohammad anzawi  >  PHP PDO database class  >  phptricksORM/Operations/Cond.php  >  Download  
File: phptricksORM/Operations/Cond.php
Role: Class source
Content type: text/plain
Description: Class source
Class: PHP PDO database class
Access databases using PDO
Author: By
Last change:
Date: 2 years ago
Size: 754 bytes
 

 

Contents

Class file image Download
<?php

namespace PHPtricks\Orm\Operations;

trait
Cond
{
   
/**
     * add limit rows to query
     * @param int $from
     * @param int $to
     * @return $this
     */
   
public function limit($from = 0, $to = 0)
    {
        if(!
$to)
        {
           
$this->_query .= " LIMIT {$from}";
        }
        else
        {
           
$this->_query .= " LIMIT {$from}, {$to}";
        }

        return
$this;
    }

   
/**
     * add OrderBy to query
     * @param string $colName
     * @param string $type
     * @return $this
     */
   
public function orderBy($colName, $type = 'ASC')
    {
       
$this->_query .= " ORDER BY {$colName} {$type}";
       
$this->_ordering = true;
        return
$this;
    }

   
   
/**
     * @param $offset
     * @return $this
     */
   
public function offset($offset)
    {
       
$this->_query .=" OFFSET " .$offset;
        return
$this;
    }
}