File tree Expand file tree Collapse file tree 2 files changed +36
-0
lines changed Expand file tree Collapse file tree 2 files changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -135,6 +135,27 @@ public static function searchCallback(array $input, callable $callback)
135
135
136
136
}
137
137
138
+ /**
139
+ * Возвращает новый датасет, индекс для строк которого равен значению колонки строки
140
+ * Предназначен для переформатирования PDO-ответов, полученных в режиме FETCH_ASSOC
141
+ *
142
+ * [ 0 => [ 'id' => 5, 'data' => 10], 1 => [ 'id' => 6, 'data' => 12] .. ]
143
+ * При вызове с аргументами ($dataset, 'id') возвращает
144
+ * [ 5 => [ 'id' => 5, 'data' => 10], 6 => [ 'id' => 6, 'data' => 12] .. ]
145
+ *
146
+ * @param $dataset
147
+ * @param $column_id
148
+ * @return array
149
+ */
150
+ public static function groupDatasetByColumn ($ dataset , $ column_id )
151
+ {
152
+ $ result = [];
153
+ array_map (function ($ row ) use (&$ result , $ column_id ){
154
+ $ result [ $ row [ $ column_id ] ] = $ row ;
155
+ }, $ dataset );
156
+ return $ result ;
157
+ }
158
+
138
159
139
160
140
161
}
Original file line number Diff line number Diff line change @@ -88,4 +88,19 @@ public static function read_all_files($root = '.')
88
88
return $ directory_content ;
89
89
}
90
90
91
+ /**
92
+ *
93
+ * @param $path
94
+ * @return bool
95
+ */
96
+ public static function checkPath ($ path )
97
+ {
98
+ if (!is_dir ( $ path ) && !mkdir ( $ path , 0777 , true ) && !is_dir ( $ path )) {
99
+ return false ;
100
+ //throw new \RuntimeException( sprintf( 'Directory "%s" was not created', $path ) );
101
+ }
102
+
103
+ return true ;
104
+ }
105
+
91
106
}
You can’t perform that action at this time.
0 commit comments