Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
syncEnrollments
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Yeray Santana Hualde
syncEnrollments
Commits
484a7373
Commit
484a7373
authored
Feb 24, 2012
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make the pdo fetch style configurable.
parent
9804bb55
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
6 deletions
+41
-6
database.php
application/config/database.php
+14
-2
config.php
laravel/config.php
+4
-3
connection.php
laravel/database/connection.php
+23
-1
No files found.
application/config/database.php
View file @
484a7373
...
@@ -16,6 +16,20 @@ return array(
...
@@ -16,6 +16,20 @@ return array(
'profile'
=>
true
,
'profile'
=>
true
,
/*
|--------------------------------------------------------------------------
| PDO Fetch Style
|--------------------------------------------------------------------------
|
| By default, database results will be returned as instances of the PHP
| stdClass object; however, you may wish to retrieve records as arrays
| instead of objects. Here you can control the PDO fetch style of the
| database queries run by your application.
|
*/
'fetch'
=>
PDO
::
FETCH_CLASS
,
/*
/*
|--------------------------------------------------------------------------
|--------------------------------------------------------------------------
| Default Database Connection
| Default Database Connection
...
@@ -43,8 +57,6 @@ return array(
...
@@ -43,8 +57,6 @@ return array(
| so make sure you have the PDO drivers for your particlar database of
| so make sure you have the PDO drivers for your particlar database of
| choice installed on your machine.
| choice installed on your machine.
|
|
| Drivers: 'mysql', 'pgsql', 'sqlsrv', 'sqlite'.
|
*/
*/
'connections'
=>
array
(
'connections'
=>
array
(
...
...
laravel/config.php
View file @
484a7373
...
@@ -56,13 +56,14 @@ class Config {
...
@@ -56,13 +56,14 @@ class Config {
* </code>
* </code>
*
*
* @param string $key
* @param string $key
* @param mixed $default
* @return array
* @return array
*/
*/
public
static
function
get
(
$key
)
public
static
function
get
(
$key
,
$default
=
null
)
{
{
list
(
$bundle
,
$file
,
$item
)
=
static
::
parse
(
$key
);
list
(
$bundle
,
$file
,
$item
)
=
static
::
parse
(
$key
);
if
(
!
static
::
load
(
$bundle
,
$file
))
return
;
if
(
!
static
::
load
(
$bundle
,
$file
))
return
value
(
$default
)
;
$items
=
static
::
$items
[
$bundle
][
$file
];
$items
=
static
::
$items
[
$bundle
][
$file
];
...
@@ -75,7 +76,7 @@ class Config {
...
@@ -75,7 +76,7 @@ class Config {
}
}
else
else
{
{
return
array_get
(
$items
,
$item
);
return
array_get
(
$items
,
$item
,
$default
);
}
}
}
}
...
...
laravel/database/connection.php
View file @
484a7373
...
@@ -145,7 +145,7 @@ class Connection {
...
@@ -145,7 +145,7 @@ class Connection {
// and deletes we will return the affected row count.
// and deletes we will return the affected row count.
if
(
stripos
(
$sql
,
'select'
)
===
0
)
if
(
stripos
(
$sql
,
'select'
)
===
0
)
{
{
return
$
statement
->
fetchAll
(
PDO
::
FETCH_CLASS
,
'stdClass'
);
return
$
this
->
fetch
(
$statement
,
Config
::
get
(
'database.fetch'
)
);
}
}
elseif
(
stripos
(
$sql
,
'update'
)
===
0
or
stripos
(
$sql
,
'delete'
)
===
0
)
elseif
(
stripos
(
$sql
,
'update'
)
===
0
or
stripos
(
$sql
,
'delete'
)
===
0
)
{
{
...
@@ -212,6 +212,28 @@ class Connection {
...
@@ -212,6 +212,28 @@ class Connection {
return
array
(
$statement
,
$result
);
return
array
(
$statement
,
$result
);
}
}
/**
* Fetch all of the rows for a given statement.
*
* @param PDOStatement $statement
* @param int $style
* @return array
*/
protected
function
fetch
(
$statement
,
$style
)
{
// If the fetch style is "class", we'll hydrate an array of PHP
// stdClass objects as generic containers for the query rows,
// otherwise we'll just use the fetch styel value.
if
(
$style
===
PDO
::
FETCH_CLASS
)
{
return
$statement
->
fetchAll
(
PDO
::
FETCH_CLASS
,
'stdClass'
);
}
else
{
return
$statement
->
fetchAll
(
$style
);
}
}
/**
/**
* Log the query and fire the core query event.
* Log the query and fire the core query event.
*
*
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment