Added the zend framework 2 library, the path is specified in line no.26 in zend_modul...
[openemr.git] / interface / modules / zend_modules / library / Zend / Db / Sql / Predicate / In.php
blob5928ecf002b7cd4d7b89e4e5685112bf4f7ef6db
1 <?php
2 /**
3 * Zend Framework (http://framework.zend.com/)
5 * @link http://github.com/zendframework/zf2 for the canonical source repository
6 * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
7 * @license http://framework.zend.com/license/new-bsd New BSD License
8 */
10 namespace Zend\Db\Sql\Predicate;
12 use Zend\Db\Sql\Exception;
13 use Zend\Db\Sql\Select;
15 class In implements PredicateInterface
17 protected $identifier;
18 protected $valueSet;
20 protected $selectSpecification = '%s IN %s';
21 protected $valueSpecSpecification = '%%s IN (%s)';
23 /**
24 * Constructor
26 * @param null|string $identifier
27 * @param array $valueSet
29 public function __construct($identifier = null, $valueSet = null)
31 if ($identifier) {
32 $this->setIdentifier($identifier);
34 if ($valueSet) {
35 $this->setValueSet($valueSet);
39 /**
40 * Set identifier for comparison
42 * @param string $identifier
43 * @return In
45 public function setIdentifier($identifier)
47 $this->identifier = $identifier;
48 return $this;
51 /**
52 * Get identifier of comparison
54 * @return null|string
56 public function getIdentifier()
58 return $this->identifier;
61 /**
62 * Set set of values for IN comparison
64 * @param array $valueSet
65 * @throws Exception\InvalidArgumentException
66 * @return In
68 public function setValueSet($valueSet)
70 if (!is_array($valueSet) && !$valueSet instanceof Select) {
71 throw new Exception\InvalidArgumentException(
72 '$valueSet must be either an array or a Zend\Db\Sql\Select object, ' . gettype($valueSet) . ' given'
75 $this->valueSet = $valueSet;
76 return $this;
79 public function getValueSet()
81 return $this->valueSet;
84 /**
85 * Return array of parts for where statement
87 * @return array
89 public function getExpressionData()
91 $values = $this->getValueSet();
92 if ($values instanceof Select) {
93 $specification = $this->selectSpecification;
94 $types = array(self::TYPE_VALUE);
95 $values = array($values);
96 } else {
97 $specification = sprintf($this->valueSpecSpecification, implode(', ', array_fill(0, count($values), '%s')));
98 $types = array_fill(0, count($values), self::TYPE_VALUE);
101 $identifier = $this->getIdentifier();
102 array_unshift($values, $identifier);
103 array_unshift($types, self::TYPE_IDENTIFIER);
105 return array(array(
106 $specification,
107 $values,
108 $types,