[ Index ]

PHP Cross Reference of Limb3

title

Body

[close]

/dbal/src/criteria/ -> lmbSQLCriteria.class.php (source)

   1  <?php
   2  /*

   3   * Limb PHP Framework

   4   *

   5   * @link http://limb-project.com

   6   * @copyright  Copyright &copy; 2004-2007 BIT(http://bit-creative.com)

   7   * @license    LGPL http://www.gnu.org/copyleft/lesser.html

   8   */
   9  lmb_require(dirname(__FILE__) . '/lmbSQLRawCriteria.class.php');
  10  
  11  /**

  12   * class lmbSQLCriteria.

  13   *

  14   * @package dbal

  15   * @version $Id: lmbSQLCriteria.class.php 6007 2007-06-20 06:31:15Z serega $

  16   */
  17  class lmbSQLCriteria extends lmbSQLRawCriteria
  18  {
  19    function __construct($raw_criteria = '', $values = array())
  20    {
  21      if(!$raw_criteria)
  22        $raw_criteria = '1 = 1';
  23  
  24      parent :: __construct($raw_criteria, $values);
  25    }
  26  
  27    static function objectify($args)
  28    {
  29      if(is_null($args))
  30        return new lmbSQLRawCriteria("1 = 1");
  31  
  32      if(is_array($args))
  33      {
  34        //array(new lmbSQLRawCriteria(..))

  35        if(is_object($args[0]))
  36          return $args[0];
  37  
  38        //array('id=1')

  39        if(!isset($args[1]) && isset($args[0]))
  40          return new lmbSQLRawCriteria($args[0]);
  41        //array('id=?', array(1))

  42        elseif(isset($args[0]) && is_array($args[1]))
  43          return new lmbSQLRawCriteria($args[0], $args[1]);
  44        //array('id=?', 1)

  45        elseif(isset($args[0]))
  46        {
  47          $sql = array_shift($args);
  48          return new lmbSQLRawCriteria($sql, $args);
  49        }
  50      }
  51      //id=1

  52      elseif(is_string($args))
  53      {
  54        return new lmbSQLRawCriteria($args);
  55      }
  56      //new lmbSQLRawCriteria(..)

  57      elseif(is_object($args))
  58      {
  59        return $args;
  60      }
  61    }
  62  }
  63  ?>


Generated: Fri Aug 29 04:49:26 2008 Cross-referenced by PHPXref 0.7