18 foreach ($keyAndValues as $key => $value) {
26 foreach ($keyAndValues as $key => $value) {
32 public static function getWhere($keyAndValues) {
34 foreach ($keyAndValues as $key => $value) {
35 $ret [] = self::$quote . $key . self::$quote .
'= :' . $key;
37 return \implode(
' AND ', $ret);
42 foreach ($pkKeyAndValues as $key => $value) {
43 $ret [] = self::$quote . \trim($key,
'___') . self::$quote .
'= :' . $key;
45 return \implode(
' AND ', $ret);
50 foreach ($values as $value) {
51 $ret [] = self::$quote . $field . self::$quote .
"='" . $value .
"'";
53 return \implode(
' OR ', $ret);
56 public static function getSearchWhere($likeOp, $fields, $value, $jokerBefore =
'%', $jokerAfter =
'%') {
58 foreach ($fields as $field) {
59 $ret [] = self::$quote . $field . self::$quote . $likeOp . $jokerBefore . $value . $jokerAfter;
61 return \implode(
' OR ', $ret);
65 return \implode(
',', self::getQuotedKeys($keyAndValues));
69 return \implode(
',', self::getParameters($keyAndValues));
74 foreach ($keyAndValues as $key => $value) {
75 $ret [] = self::$quote . $key . self::$quote .
'= :' . $key;
77 return \implode(
',', $ret);
82 foreach ($keyAndValues as $key => $value) {
83 $ret [] = self::$quote . $key . self::$quote .
'= :' . $key;
85 return \implode(
',', $ret);
89 if ($condition !=
null && \stristr($condition,
' join ') ===
false) {
90 $condition =
' WHERE ' . $condition;
96 if (\strpos($condition,
'?') !== -1) {
97 foreach ($params as $k => $v) {
103 $condition = \str_replace(
'?',
":$k", $condition);
109 public static function getCondition($keyValues, $classname =
null, $separator =
' AND ') {
110 if (!\is_array($keyValues)) {
113 if ((\array_keys($keyValues) === \range(0, \count($keyValues) - 1))) {
114 if (isset ($classname)) {
115 $keys = OrmUtils::getKeyFields($classname);
116 if (\is_array($keys)) {
117 $keyValues = \array_combine($keys, $keyValues);
122 foreach ($keyValues as $key => $value) {
123 $retArray [] = self::$quote . $key . self::$quote .
" = '" . $value .
"'";
125 return \implode($separator, $retArray);
136 if (!\is_array($fields)) {
141 if (\is_string($tableName)) {
142 $prefix = self::$quote . $tableName . self::$quote .
'.';
144 foreach ($fields as $field) {
145 $result [] = $prefix . self::$quote . $field .
self::$quote;
147 return \implode(
',', $result);
static getInsertFields($keyAndValues)
static getCondition($keyValues, $classname=null, $separator=' AND ')
static getParameters($keyAndValues)
static getUpdateFieldsKeyAndValues($keyAndValues)
static getUpdateFieldsKeyAndParams($keyAndValues)
static checkWhereParams($condition, &$params=[])
static getFieldList($fields, $tableName=false)
static checkWhere($condition)
static getQuotedKeys($keyAndValues)
static getSearchWhere($likeOp, $fields, $value, $jokerBefore='%', $jokerAfter='%')
static getWherePK($pkKeyAndValues)
static getWhere($keyAndValues)
static getMultiWhere($values, $field)
static getInsertFieldsValues($keyAndValues)
Object/relational mapping utilities.