|
| prepareColumnsList (\Magento\Framework\DB\Select $select, $groupByCondition=null) |
|
| addGroupConcatColumn ( $select, $fieldAlias, $fields, $groupConcatDelimiter=',', $fieldsDelimiter='', $additionalWhere='') |
|
| getDateDiff ($startDate, $endDate) |
|
| addLikeEscape ($value, $options=[]) |
|
| __construct (\Magento\Framework\App\ResourceConnection $resource, $modulePrefix) |
|
| escapeLikeValue ($value, $options=[]) |
|
| addLikeEscape ($value, $options=[]) |
|
| getCILike ($field, $value, $options=[]) |
|
Definition at line 11 of file Helper.php.
◆ _assembleLimit()
_assembleLimit |
( |
|
$query, |
|
|
|
$limitCount, |
|
|
|
$limitOffset, |
|
|
|
$columnList = [] |
|
) |
| |
|
protected |
- Parameters
-
string | $query | |
int | $limitCount | |
int | $limitOffset | |
array | $columnList | |
- Returns
- string
Definition at line 153 of file Helper.php.
155 if ($limitCount !==
null) {
156 $limitCount = intval($limitCount);
157 if ($limitCount <= 0) {
161 $limitOffset = intval($limitOffset);
162 if ($limitOffset < 0) {
166 if ($limitOffset + $limitCount != $limitOffset + 1) {
168 foreach ($columnList as $columnEntry) {
169 $columns[] = $columnEntry[2] ? $columnEntry[2] : $columnEntry[1];
171 $query = sprintf(
'%s LIMIT %s, %s',
$query, $limitCount, $limitOffset);
◆ _prepareGroup()
Returns quoted group by fields
- Parameters
-
\Magento\Framework\DB\Select | $select | |
bool | $autoReset | |
- Returns
- array
Definition at line 80 of file Helper.php.
88 foreach ($selectGroups as $term) {
89 $groups[] = $this->
getConnection()->quoteIdentifier($term,
true);
◆ _prepareHaving()
Prepare and returns having array
- Parameters
-
\Magento\Framework\DB\Select | $select | |
bool | $autoReset | |
- Returns
- array
- Exceptions
-
Looking for column expression in the having clause
Replace column expression to column alias in having clause
Definition at line 107 of file Helper.php.
110 if (!$selectHavings) {
116 foreach (
$columns as $columnEntry) {
117 $correlationName = (string)$columnEntry[1];
118 $column = $columnEntry[2];
119 foreach ($selectHavings as $having) {
123 if (strpos($having, $correlationName) !==
false) {
124 if (is_string($column)) {
128 $havings[] = str_replace($correlationName, $column, $having);
130 throw new \Zend_Db_Exception(
131 sprintf(
"Can't prepare expression without column alias: '%s'", $correlationName)
◆ _prepareOrder()
Returns array of quoted orders with direction
- Parameters
-
\Magento\Framework\DB\Select | $select | |
bool | $autoReset | |
- Returns
- array
Definition at line 20 of file Helper.php.
28 foreach ($selectOrders as $term) {
29 if (is_array($term)) {
30 if (!is_numeric($term[0])) {
34 if (!is_numeric($term)) {
◆ _truncateAliasName()
_truncateAliasName |
( |
|
$field, |
|
|
|
$reverse = false |
|
) |
| |
|
protected |
Truncate alias name from field.
Result string depends from second optional argument $reverse which can be true if you need the first part of the field. Field can be with 'dot' delimiter.
- Parameters
-
string | $field | |
bool | $reverse | OPTIONAL |
- Returns
- string
Definition at line 58 of file Helper.php.
61 if (!is_numeric($field) && (strpos($field,
'.') !==
false)) {
62 $size = strpos($field,
'.');
64 $string = substr($field, 0, $size);
66 $string = substr($field, $size + 1);
◆ addGroupConcatColumn()
addGroupConcatColumn |
( |
|
$select, |
|
|
|
$fieldAlias, |
|
|
|
$fields, |
|
|
|
$groupConcatDelimiter = ',' , |
|
|
|
$fieldsDelimiter = '' , |
|
|
|
$additionalWhere = '' |
|
) |
| |
Add prepared column group_concat expression
- Parameters
-
\Magento\Framework\DB\Select | $select | |
string | $fieldAlias | Field alias which will be added with column group_concat expression |
string | $fields | |
string | $groupConcatDelimiter | |
string | $fieldsDelimiter | |
string | $additionalWhere | |
- Returns
- \Magento\Framework\DB\Select
Definition at line 241 of file Helper.php.
254 if ($additionalWhere) {
255 $fieldExpr = $this->
getConnection()->getCheckSql($additionalWhere, $fieldExpr,
"''");
258 if ($groupConcatDelimiter) {
259 $separator = sprintf(
" SEPARATOR '%s'", $groupConcatDelimiter);
261 $select->columns([$fieldAlias =>
new \
Zend_Db_Expr(sprintf(
'GROUP_CONCAT(%s%s)', $fieldExpr, $separator))]);
◆ addLikeEscape()
addLikeEscape |
( |
|
$value, |
|
|
|
$options = [] |
|
) |
| |
Escapes and quotes LIKE value. Stating escape symbol in expression is not required, because we use standard MySQL escape symbol. For options and escaping see escapeLikeValue().
- Parameters
-
string | $value | |
array | $options | |
- Returns
- \Zend_Db_Expr
- See also
- escapeLikeValue()
Definition at line 289 of file Helper.php.
escapeLikeValue($value, $options=[])
◆ getDateDiff()
getDateDiff |
( |
|
$startDate, |
|
|
|
$endDate |
|
) |
| |
Returns expression of days passed from $startDate to $endDate
- Parameters
-
string | \Zend_Db_Expr | $startDate | |
string | \Zend_Db_Expr | $endDate | |
- Returns
- \Zend_Db_Expr
Definition at line 272 of file Helper.php.
274 $dateDiff =
'(TO_DAYS(' . $endDate .
') - TO_DAYS(' . $startDate .
'))';
275 return new \Zend_Db_Expr($dateDiff);
◆ prepareColumnsList()
Prepare select column list
- Parameters
-
\Magento\Framework\DB\Select | $select | |
string | null | $groupByCondition | OPTIONAL |
- Returns
- mixed|array
- Exceptions
-
Definition at line 188 of file Helper.php.
196 $preparedColumns = [];
198 foreach (
$columns as $columnEntry) {
199 list($correlationName, $column,
$alias) = $columnEntry;
202 if (preg_match(
'/(^|[^a-zA-Z_])^(SELECT)?(SUM|MIN|MAX|AVG|COUNT)\s*\(/i', $column)) {
203 $column = new \Zend_Db_Expr($column);
205 $preparedColumns[strtoupper(
$alias)] = [
null, $column,
$alias];
207 throw new \Zend_Db_Exception(
"Can't prepare expression without alias");
211 if ($tables[$correlationName][
'tableName'] instanceof \
Zend_Db_Expr) {
212 throw new \Zend_Db_Exception(
213 "Can't prepare expression when tableName is instance of \Zend_Db_Expr" 216 $tableColumns = $this->
getConnection()->describeTable($tables[$correlationName][
'tableName']);
217 foreach (array_keys($tableColumns) as $col) {
218 $preparedColumns[strtoupper($col)] = [$correlationName, $col,
null];
222 $preparedColumns[strtoupper($columnKey)] = [$correlationName, $column,
$alias];
227 return $preparedColumns;
The documentation for this class was generated from the following file: