/** * @param array $where * @return array * @throws \Exception */ protected function formatKey($where) { if (isset($where[self::KEY_FIELD])) { $key = $where[self::KEY_FIELD]; unset($where[self::KEY_FIELD]); } if (isset($where[self::KEYDATA_FIELD])) { $keydata = $where[self::KEYDATA_FIELD]; unset($where[self::KEYDATA_FIELD]); } if (isset($where[self::FIELDS_FIELD])) { $fields = $where[self::FIELDS_FIELD]; unset($where[self::FIELDS_FIELD]); } if (isset($key) && isset($keydata)) { if (is_array($key) && is_array($keydata)) { foreach ($key as $k) { if (!array_key_exists($k, $keydata)) { $keydata[$k] = null; } } $where['AND'] = $keydata; } elseif (is_string($key)) { $where['AND'] = [$key => $keydata]; } else { $msg = Message::messageList(5); throw $msg->getException(); } } elseif (isset($fields) && isset($keydata)) { $wh = $this->formatSearch($fields, $keydata); $where['OR'] = $wh; } return $where; }
/** * @param array $config * @throws \Exception */ protected function initEngine($config) { if (isset($config['engine'])) { $fc = new \ReflectionClass($config['engine']); if ($fc->implementsInterface('\\Wwtg99\\DataPool\\Common\\IDataEngine')) { $this->engine = $fc->newInstance(); $this->engine->init($config); } else { $msg = Message::messageList(2); throw $msg->getException(); } } }