*
@param $model
@param $fields
@param string $value
@param null $orderBy
@param bool $responseType
@param int $limit
@return string
162339
public function search($model , $fields , $value = "" , $select = null ,  $orderBy = null , $responseType = true , $limit = 10){
        $this->model = ucfirst($model);
        $this->fields = $fields;
        $this->limit  = $limit;
        $this->value = $value;
        $this->type = $responseType;
        $this->order = $orderBy;
        $this->select = $select;
        return $this->init();
    }
396161
public final function FirstByField($field, $value, Sql\OrderList $orderBy = null, Sql\GroupList $groupBy = null)
    {
        $result = $this->FetchByField(false, $field, $value, $orderBy, $groupBy, 0, 1);
        if (count($result))
            return $result[0];
    }
559558
public function getFromEntity($entity, array $formParameters, $limitFields = null)
    {
        $extracted_data = array();

        foreach($formParameters as $field) {
            $getter_name = "get".$this->dashesToCamelCase($field);

            if (($limitFields === null || in_array($field, $limitFields)) && method_exists($entity, $getter_name) && ($value = $entity->$getter_name()) !== null) {
                $extracted_data[$field] = $value;
            }
        }

        return $extracted_data;
    }
591910
public function findByField($field, $value = null, $columns = ['*'])
    {
        $this->applyCriteria();
        $this->applyScope();
        $model = $this->model->where($field, '=', $value)->get($columns);
        $this->resetModel();

        return $this->parserResult($model);
    }
32241
public function find($table, $fields = null, $where = null, $order = null, $limit = null, $offset = null, $array = array(), $fetchMode = \PDO::FETCH_ASSOC)
     {
         $sql = ' SELECT '.(($fields) ?? '*').' FROM '.(($table)).(($where) ? ' WHERE '.$where : ' ')
            .(($limit) ? ' LIMIT '.$limit : ' ')
            .(($offset && $limit) ? ' OFFSET '.$offset : ' ')
            .(($order) ? ' ORDER BY '.$order : ' ');

         $stmt = $this->conn->prepare($sql);

         foreach ($array as $key => $values) {
             return  $stmt->bindValue("$key", $values);
         }
         $stmt->execute();

         do {
             return $stmt->fetchAll($fetchMode);
         } while (
            $stmt->nextRowset());
         $stmt->close();
     }
1048220
public static function values($field, $filters = null)
    {
        if (!is_string($field)) {
            throw new ParameterOrderException(__METHOD__ . ' field');
        }
        return static::query()->where($filters)->values($field);
    }
422786
public function fieldSelect($table, $fields, $where, $orderBy = null)
    {
        $table = $this->getTableName($table);

        $query = "SELECT ";

        if (substr($this->mode, 0, 5) === "mssql") {
            $query .= "TOP 1 ";
        }

        $query .= $this->selectFields($fields);

        $query .= " FROM " . $table . " ";

        $params = null;
        if ($where !== self::NO_WHERE_CLAUSE) {
            $query .= "WHERE " . $this->where($where, $params);
        }

        if ($orderBy) {
            $query .= $this->orderBy($orderBy) . " ";
        }

        switch ($this->mode) {

            case "mysql":
            case "postgres":
            case "redshift":
            case "sqlite":
                $query .= "LIMIT 1";
                break;

            case "odbc":
                $query .= "FETCH FIRST 1 ROW ONLY";
                break;
        }

        return $this->query($query, $params)->fetch();
    }
1090745
public function display(string $fieldname, $value, string $model = null)
    {
        $return = '';
        foreach ($value as $k => $v) {
            $return .= $k . ': ' . $v . '</br>';
        }

        return $return;
    }
329425
public static function getGridColumns($model, $fields)
    {
        if (!$model instanceof ActiveRecord) {
            return $model->attributes();
        }

        /** @var ActiveRecord $model */
        list($behaviorAttributes, $blameableAttributes) = self::getModelBehaviorAttributes($model);
        /** @var LabelsBehavior $labelsBehavior */
        $labelsBehavior = $model->getBehavior('labels');
        $versionAttribute = $model->optimisticLock();
        $formats = $model->attributeFormats();
        $keys    = self::getModelKeys($model);

        $columns = [];
        foreach ($fields as $key => $field) {
            // for arrays and callables, don't generate the column, use the one provided
            if (is_array($field)) {
                $columns[$key] = $field;
                continue;
            } elseif (!is_string($field) && is_callable($field)) {
                $columns[$key] = call_user_func($field, $model);
                continue;
            }
            // if the field is from a relation (eg. client.firstname) treat it as an attribute
            $format = isset($formats[$field]) ? $formats[$field] : $model->getAttributeFormat($field);
            if ($format === 'paragraphs') {
                $format = 'shortText';
            }
            if ($format !== null) {
                if ((in_array($field, $keys)
                        && ($labelsBehavior === null || !in_array($field, $labelsBehavior->attributes)))
                    || in_array($field, $behaviorAttributes)
                    || $field === $versionAttribute
                ) {
                    continue;
                }
                if (in_array($field, $labelsBehavior->attributes)) {
                    $columns[] = static::getLinkedColumn($model, $field);
                    continue;
                }
                $columns[] = static::getAttributeColumn($model, $field, $format);
                continue;
            }

            $relation = $model->getRelation($field);
            foreach ($relation->link as $left => $right) {
                if (in_array($right, $blameableAttributes)) {
                    continue 2;
                }
            }

            if (!Yii::$app->user->can($relation->modelClass . '.read')) {
                continue;
            }
            $columns[] = static::getRelationColumn($model, $field, $relation);
        }

        return $columns;
    }
1333109
public function selectArray($fields = null, $where = null, $orderBy = null, $limit = null): array
    {
        return self::select2($fields, $where, $orderBy, $limit);
    }
389103
public function getOrderBy($field)
    {
        return array_key_exists($field, $this->orderBy) ?
                  $this->orderBy[$field]
                : null;
    }
288596
private static function decodeInsideModelFields(array $responseArray, BunqModel $model, int $depthCounter)
    {
        $modelFields = (array_keys(get_object_vars($model)));

        foreach ($modelFields as $field) {
            $fieldClass = ModelUtil::getModelClassNameQualifiedOrNull($field);

            if (is_null($fieldClass)) {
                continue;
            }

            $reflectionClass = new ReflectionClass($fieldClass);
            /** @var BunqModel $bunqModelSubClass */
            $bunqModelSubClass = $reflectionClass->newInstanceWithoutConstructor();
            $fieldContents = $bunqModelSubClass::createFromResponseArrayAnchorObject(
                $responseArray,
                $depthCounter + self::DEPTH_COUNTER_INCREMENTER
            );

            if ($fieldContents->isAllFieldNull()) {
                $model->{$field} = null;
            } else {
                $model->{$field} = $fieldContents;
            }
        }

        return $model;
    }
483177
public function read($model, $ids, $fields = array())
	{
		$params = $this->buildParams(array(
			$model,
			'read',
			$ids,
			$fields
		));

		$response = $this->getClient('object')->call('execute', $params);

		return $response;
	}
632897
public static function pages($order_by = '', $where = null, $limit = 50, $offset = 0) {
        $module = \jacmoe\mdpages\Module::getInstance();
        if(!is_null($module)) {
            $controller = \Yii::$app->controller;
            if(!is_null($controller)) {
                if($controller->id == 'page') {
                    $repo = $controller->getFlywheelRepo();
                    if(empty($order_by)) {
                        if(isset($where)) {
                            list($field, $operator, $value) = $where;
                            return $repo->query()->limit($limit, $offset)->where($field, $operator, $value)->execute();
                        } else {
                            return $repo->query()->limit($limit, $offset)->execute();
                        }
                    } else {
                        if(isset($where)) {
                            list($field, $operator, $value) = $where;
                            return $repo->query()->limit($limit, $offset)->where($field, $operator, $value)->orderBy($order_by)->execute();
                        } else {
                            return $repo->query()->limit($limit, $offset)->orderBy($order_by)->execute();
                        }
                    }
                }
                throw new NotSupportedException("Can only be used when active controller is 'page'.");
            }
        }
        throw new NotSupportedException("Can't be called outside of jacmoe\mdpages module.");
    }
1074390
public function executeGetColumnData($model, $params = [])
	{
		$value = null;
		if (isset($params['value']) && $params['value'] !== null) {
			if (is_string($params['value'])) {
				$value = ArrayHelper::getValue($model, $params['value']);
			} else {
				$value = call_user_func($params['value'], $model, $this);
			}
		} elseif (isset($params['attribute']) && $params['attribute'] !== null) {
			$value = ArrayHelper::getValue($model, $params['attribute']);
		}

		if (isset($params['format']) && $params['format'] != null)
			$value = $this->formatter()->format($value, $params['format']);

		return $value;
	}
290356
public function formatOutputRecord($data, $model=null)
    {
        $model = $model ? : $this;
        
        if (!$data || !isset($model['primary_key']) || !isset($model['fields'])) {
            return $data;
        }
        
        $fields_names = array_keys($model['fields']);
        foreach ($data as $k => $v){
            if (in_array($k, $fields_names)) {
                $data[$k] = FieldOutputHandler::formatValue($model['fields'][$k], $v);
            }
        }
        
        return $data;
    }
183801
public function display(string $fieldname, $value, string $model = null)
    {
        $value = $value === true ? 'true' : 'false';

        return $value;
    }