@return array [params, valueParts]

@throws DBALManagerException when number of columns and values does not match
516782
protected static function generateMultiParams(array $rows, array $columns): array
    {
        //for integrity check
        $count = count($columns);

        $valueParts = [];
        $params = [];

        foreach ($rows as $row) {
            if (count($row) !== $count) {
                throw new DBALManagerException('Number of columns and values does not match.');
            }
            $marks = [];
            foreach ($row as $value) {
                $marks[] = '?';
                $params[] = $value;
            }
            $valueParts[] = '(' . implode(', ', $marks) . ')';
        }

        return [
            'params' => $params,
            'valueParts' => $valueParts,
        ];
    }
1000614
private function bindTypedParameters()
    {
        $streams = $values = [];
        $types   = $this->types;

        foreach ($this->_bindedValues as $parameter => $value) {
            if (! isset($types[$parameter - 1])) {
                $types[$parameter - 1] = static::$_paramTypeMap[ParameterType::STRING];
            }

            if ($types[$parameter - 1] === static::$_paramTypeMap[ParameterType::LARGE_OBJECT]) {
                if (is_resource($value)) {
                    if (get_resource_type($value) !== 'stream') {
                        throw new InvalidArgumentException('Resources passed with the LARGE_OBJECT parameter type must be stream resources.');
                    }
                    $streams[$parameter] = $value;
                    $values[$parameter]  = null;
                    continue;
                }

                $types[$parameter - 1] = static::$_paramTypeMap[ParameterType::STRING];
            }

            $values[$parameter] = $value;
        }

        if (! $this->_stmt->bind_param($types, ...$values)) {
            throw new MysqliException($this->_stmt->error, $this->_stmt->sqlstate, $this->_stmt->errno);
        }

        $this->sendLongData($streams);
    }
638165
public function parseDbTable()
    {
        try {
            if (Schema::hasTable($this->getTable())) {
                $fields = collect(Schema::getColumnListing($this->getTable()))->diff([
                    'id',
                    'ID',
                    'Id',
                    'created_at',
                    'updated_at',
                    'deleted_at',
                ]);

                return $fields;
            }

            return collect([]);
        } catch (\Exception $e) {
            throw new \Exception('Database is not connected');
        }
    }
699592
private function getExtendedFieldValuesMultiple(
        $extendedFieldList = [],
        $leadIds = []
    ) {
        /** @var EntityManager $em */
        $em = $this->getEntityManager();

        $leadIdsStr = "'".implode("','", $leadIds)."'";

        $selects = [];
        foreach (['string', 'float', 'boolean', 'date', 'datetime', 'time', 'text'] as $data_type) {
            foreach (['', '_secure'] as $secure) {
                $xrefTable = MAUTIC_TABLE_PREFIX."lead_fields_leads_{$data_type}{$secure}_xref";

                $selects[] = <<<EOSQL
SELECT lead_id, lead_field_id, value, '{$data_type}' AS data_type 
FROM  {$xrefTable}
WHERE lead_id IN ({$leadIdsStr})
EOSQL;
            }
        }
        $xrefQuery = implode("\nUNION\n", $selects);

        $leadsTable      = $em->getRepository('MauticLeadBundle:Lead')->getTableName();
        $lt              = $em->getRepository('MauticLeadBundle:Lead')->getTableAlias();
        $leadFieldsTable = $em->getRepository('MauticLeadBundle:LeadField')->getTableName();
        $lft             = $em->getRepository('MauticLeadBundle:LeadField')->getTableAlias();

        $where = "{$lft}.object IN ('extendedField','extendedFieldSecure') ";
        if (!empty($extendedFieldList)) {
            $ids             = array_map(
                function ($e) {
                    return $e['id'];
                },
                $extendedFieldList
            );
            $leadFiieldIdStr = "'".implode("','", $ids)."'";
            $where           = "{$lft}.id IN ({$leadFiieldIdStr}) ";
        }

        $sql = <<<EOSQL
SELECT x.lead_id, x.alias, v.value, v.data_type
FROM
(
    SELECT {$lt}.id AS lead_id,
    {$lft}.id as lead_field_id,
    {$lft}.alias
    FROM {$leadsTable} {$lt} CROSS JOIN {$leadFieldsTable} {$lft}
    WHERE {$where}
    AND {$lt}.id  IN ({$leadIdsStr})
) x
LEFT JOIN
(
    {$xrefQuery}
) v USING (lead_id, lead_field_id)
EOSQL;

        $query = $em->getConnection()->prepare($sql);
        $query->execute();
        $results = $query->fetchAll();

        // Group results by leadId.
        $leads = [];
        foreach ($results as $row => $result) {
            $leads[$result['lead_id']][$result['alias']] = $result['value'];
            unset($results[$row]);
        }

        return $leads;
    }
92591
protected function GetColumns()
	{
		if (!$this->ModelName)
		{
			throw new Exception("ModelName must be defined in " . get_class($this) . "::GetColumns");
		}

		$counter = 0;
		$props = array();
		foreach (get_class_vars($this->ModelName)as $var => $val)
		{
			$props[$counter++] = $var;
		}
		return $props;
	}
903733
private function getDatatableColumns(): array
    {
        $result = $this->getDisplayColumns();

        if (!$this->getGroupByField()) {
            $result[] = Utility::MENU_PROPERTY_NAME;
        }

        if (!$this->getGroupByField() && $this->batch) {
            $table = TableRegistry::get($this->entity->get('model'));
            // add primary key in FIRST position
            foreach ((array)$table->getPrimaryKey() as $primaryKey) {
                array_unshift($result, $table->aliasField($primaryKey));
            }
        }

        return $result;
    }
769329
protected function parseData()
    {
        $values = [];
        foreach ($this->parts['data'] as $key => $data) {
            foreach ($data as $value) {
                if (!is_array($value)) {
                    $value = [$value];
                }

                foreach ($value as $insertValue) {
                    $values[$key][] = $this->getManager()->getAdapter()->quote($insertValue);
                }
            }
        }
        foreach ($values as &$value) {
            $value = "(" . implode(", ", $value) . ")";
        }

        return ' VALUES ' . implode(', ', $values);
    }
266642
public function bindParams($params)
    {
        $bindParams = [''];
        
        foreach ($params as $dbColumnName => $dbColumnValue) {
            $dbColumnValueAry = (!is_array($dbColumnValue)) ? [$dbColumnValue] : $dbColumnValue;
            
            $i = 1;
            foreach ($dbColumnValueAry as $dbColumnValueAryValue) {
                ${$dbColumnName . $i} = $dbColumnValueAryValue;
                
                if (is_numeric($dbColumnValueAryValue)) {
                    $bindParams[0] .= 'i';
                } else if (is_double($dbColumnValueAryValue)) {
                    $bindParams[0] .= 'd';
                } else if (is_string($dbColumnValueAryValue)) {
                    $bindParams[0] .= 's';
                } else if (is_null($dbColumnValueAryValue)) {
                    $bindParams[0] .= 's';
                } else {
                    $bindParams[0] .= 'b';
                }
                
                $bindParams[] = &${$dbColumnName . $i};
                $i++;
            }
        }
        
        call_user_func_array([$this->statement, 'bind_param'], $bindParams);
        
        return $this;
    }
617737
public function queryValue($params = array())
    {
        $this->mergeParams($params);
        $this->beginQuery();
        $rst = $this->statement->fetchColumn();
        $this->statement->closeCursor();

        return $rst;
    }
916098
final private function getSqlKeyValues() {
		
		// force to array
		$propertyNames = (array)$this->keyProperties;

		// list to return
		$values = array();

		foreach ($propertyNames as $name) {
			$values[] = $this->{$name};
		}

		return $values;

	}
384914
public function toSearchableArray()
    {
        if (!sizeof($this->searchableColumns)) {
            $result = collect($this);
        } else {
            $result = collect([
                'id' => $this['id'],
            ]);
            foreach ($this->searchableColumns as $searchableColumn) {
                $result->put($searchableColumn, collect($this)->get($searchableColumn));
            }
        }
        if (sizeof($this->searchableInnerColumns)) {
            foreach ($this->searchableInnerColumns as $searchableInnerColumnKey => $searchableInnerColumnValue) {
                $searchableInnerColumnKey = explode('-', $searchableInnerColumnKey)[0];
                $innerModels = explode('.', $searchableInnerColumnKey);
                $values = $this;
                foreach ($innerModels as $innerModel) {
                    $values = $values->{$innerModel};
                }
                $values = collect($values);
                $result->put($searchableInnerColumnKey . '-' . $searchableInnerColumnValue,
                    collect($values)->get($searchableInnerColumnValue));
            }
        }
        if (sizeof($this->searchableManyInnerColumns)) {
            foreach ($this->searchableManyInnerColumns as $searchableInnerColumnKey => $searchableInnerColumnValue) {
                $searchableInnerColumnKey = explode('-', $searchableInnerColumnKey)[0];
                $innerModels = explode('.', $searchableInnerColumnKey);
                $values = $this;
                foreach ($innerModels as $innerModel) {
                    $values = $values->{$innerModel};
                }
                $values = collect($values);
                $counter = 0;
                foreach ($values as $value) {
                    $result->put($searchableInnerColumnKey . '-' . $searchableInnerColumnValue . '-' . $counter,
                        collect($value)->get($searchableInnerColumnValue));
                    $counter++;
                }
            }
        }
        return $result->toArray();
    }
27652
protected function _parseChangedColumns()
    {
        $columns = $this->_sql->getChangedColumns();
        $parts = [];
        foreach ($columns as $column) {
            $parts[] = $column->getName() .' '. $this->_parseColumn($column);
        }
        return implode(', CHANGE COLUMN ', $parts);
    }
503458
public static function _getValues ($params = array (), &$db = FALSE)
	{
		
		// Set select

		if (!isset ($params['select']))
		{
			$params['select']	= '*';
		}
		
		// Set from

		if (!isset ($params['from']))
		{
			$params['from']		= '`' . static::$dbTable . '`';
		}
		
		// Get database slave for read

		if ($db === FALSE)
		{
			$db	=& self::_getDbSlave ();
		}
		
		// Return value

		return $db->getValues ($params);

	}
431247
public function getRawValue(): array
	{
		$primaryValues = [];
		foreach ($this->getIterator() as $entity) {
			if ($entity->isPersisted()) {
				$primaryValues[] = $entity->getValue('id');
			}
		}
		return $primaryValues;
	}
713231
protected function buildColumns() {
		$select = [];
		$params = [];
		if(!$this->columns)
			return ['*', []];
		else {
			foreach($this->columns as $alias=>$column) {
				if($column instanceof static) {
					$sql = $column->buildSQL();
					$params = array_merge($params, $column->getParameters());
					$select[] = '('.$sql.') AS '.$this->identifierQuotes($alias);
				}
				elseif($column instanceof Raw) {
					$sql = $column->getSQL();
					$params = array_merge($params, $column->getParameters());
					$select[] = $sql.' AS '.$this->identifierQuotes($alias);
				}
				elseif((string)$alias !== (string)$column)
					$select[] = $this->identifierQuotes($column).' AS '.$this->identifierQuotes($alias);
				else
					$select[] = $this->identifierQuotes($column);
			}
		}
		return [implode(', ', $select), $params];
	}
796063
public function getParams()
    {
        $params = [];
        $dbMap = Propel::getServiceContainer()->getDatabaseMap($this->getDbName());

        foreach ($this->getMap() as $criterion) {

            $table = null;
            foreach ($criterion->getAttachedCriterion() as $attachedCriterion) {
                $tableName = $attachedCriterion->getTable();

                $table = $this->getTableForAlias($tableName);
                if (null === $table) {
                    $table = $tableName;
                }

                if (
                    ($this->isIgnoreCase() || method_exists($attachedCriterion, 'setIgnoreCase'))
                    && $dbMap->getTable($table)->getColumn($attachedCriterion->getColumn())->isText()
                ) {
                    $attachedCriterion->setIgnoreCase(true);
                }
            }

            $sb = '';
            $criterion->appendPsTo($sb, $params);
        }

        $having = $this->getHaving();
        if (null !== $having) {
            $sb = '';
            $having->appendPsTo($sb, $params);
        }

        return $params;
    }
451061
public function toRequestParams()
    {
        $ret = array(
            "name" => $this->_name,
            "description" => $this->_description
        );

        foreach ($this->_fields as $column => $fields)
        {
            foreach ($fields as $field)
            {
                if ($field instanceof ObjectField)
                {
                    $ret["fields"][$column][] = $field->toRequestParams();
                }
            }
        }
        // Convert from an assoc array to a numeric array.
        // This will move items from the 3rd column to the 2nd if the 2nd isn't populated.
        $ret["fields"] = array_values($ret["fields"]);
        return $ret;
    }