Skip to content

Commit 5115623

Browse files
committed
PDO support. fixes #50
1 parent 6276244 commit 5115623

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@ All Notable changes to `Backpack CRUD` will be documented in this file
2020
- Nothing
2121

2222

23+
## [3.0.7] - 2016-08-05
24+
25+
### Added
26+
- PDO Support;
27+
28+
### Removed
29+
- default column values on the setFromDb() function;
30+
2331

2432
## [3.0.6] - 2016-07-31
2533

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@
2727
"backpack/base": "^0.6.7",
2828
"laravelcollective/html": "~5.0",
2929
"barryvdh/laravel-elfinder": "^0.3.5",
30-
"livecontrol/eloquent-datatable": "^0.1.5"
30+
"livecontrol/eloquent-datatable": "^0.1.5",
31+
"doctrine/dbal": "^2.5"
3132
},
3233
"require-dev": {
3334
"phpunit/phpunit" : "4.*",

src/PanelTraits/AutoSet.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public function setFromDb()
2222
$new_field = [
2323
'name' => $field,
2424
'label' => ucfirst($field),
25-
'value' => null, 'default' => $this->db_column_types[$field]['default'],
25+
'value' => null,
2626
'type' => $this->getFieldTypeFromDbColumnType($field),
2727
'values' => [],
2828
'attributes' => [],
@@ -47,8 +47,12 @@ public function setFromDb()
4747
*/
4848
public function getDbColumnTypes()
4949
{
50-
foreach (\DB::select(\DB::raw('SHOW COLUMNS FROM '.$this->model->getTable())) as $column) {
51-
$this->db_column_types[$column->Field] = ['type' => trim(preg_replace('/\(\d+\)(.*)/i', '', $column->Type)), 'default' => $column->Default];
50+
$table_columns = \Schema::getColumnListing($this->model->getTable());
51+
52+
foreach ($table_columns as $key => $column) {
53+
$column_type = \Schema::getColumnType($this->model->getTable(), $column);
54+
$this->db_column_types[$column]['type'] = trim(preg_replace('/\(\d+\)(.*)/i', '', $column_type));
55+
$this->db_column_types[$column]['default'] = ''; // no way to do this using DBAL?!
5256
}
5357

5458
return $this->db_column_types;

0 commit comments

Comments
 (0)