Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
U
UserAdminV2
Overview
Overview
Details
Activity
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
庄欣
UserAdminV2
Commits
faa2eec3
Commit
faa2eec3
authored
Feb 17, 2012
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
consolidate database methods into db::query.
parent
42b9d1e0
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
48 deletions
+21
-48
laravel/database/connection.php
+16
-43
laravel/database/query.php
+4
-4
laravel/database/schema.php
+1
-1
No files found.
laravel/database/connection.php
View file @
faa2eec3
...
@@ -140,49 +140,22 @@ class Connection {
...
@@ -140,49 +140,22 @@ class Connection {
{
{
list
(
$statement
,
$result
)
=
$this
->
execute
(
$sql
,
$bindings
);
list
(
$statement
,
$result
)
=
$this
->
execute
(
$sql
,
$bindings
);
return
$statement
->
fetchAll
(
PDO
::
FETCH_CLASS
,
'stdClass'
);
// The result we return depends on the type of query executed against the
}
// database. On SELECT clauses, we will return the result set, for update
// and deletes we will return the affected row count. And for all other
/**
// queries we'll just return the boolean result.
* Execute a SQL UPDATE query and return the affected row count.
if
(
stripos
(
$sql
,
'select'
)
===
0
)
*
{
* @param string $sql
return
$statement
->
fetchAll
(
PDO
::
FETCH_CLASS
,
'stdClass'
);
* @param array $bindings
}
* @return int
elseif
(
stripos
(
$sql
,
'update'
)
===
0
or
stripos
(
$sql
,
'delete'
)
===
0
)
*/
{
public
function
update
(
$sql
,
$bindings
=
array
())
return
$statement
->
rowCount
();
{
}
list
(
$statement
,
$result
)
=
$this
->
execute
(
$sql
,
$bindings
);
else
{
return
$statement
->
rowCount
();
return
$result
;
}
}
/**
* Execute a SQL DELETE query and return the affected row count.
*
* @param string $sql
* @param array $bindings
* @return int
*/
public
function
delete
(
$sql
,
$bindings
=
array
())
{
list
(
$statement
,
$result
)
=
$this
->
execute
(
$sql
,
$bindings
);
return
$statement
->
rowCount
();
}
/**
* Execute an SQL query and return the boolean result of the PDO statement.
*
* @param string $sql
* @param array $bindings
* @return bool
*/
public
function
statement
(
$sql
,
$bindings
=
array
())
{
list
(
$statement
,
$result
)
=
$this
->
execute
(
$sql
,
$bindings
);
return
$result
;
}
}
/**
/**
...
...
laravel/database/query.php
View file @
faa2eec3
...
@@ -717,7 +717,7 @@ class Query {
...
@@ -717,7 +717,7 @@ class Query {
$sql
=
$this
->
grammar
->
insert
(
$this
,
$values
);
$sql
=
$this
->
grammar
->
insert
(
$this
,
$values
);
return
$this
->
connection
->
statement
(
$sql
,
$bindings
);
return
$this
->
connection
->
query
(
$sql
,
$bindings
);
}
}
/**
/**
...
@@ -731,7 +731,7 @@ class Query {
...
@@ -731,7 +731,7 @@ class Query {
{
{
$sql
=
$this
->
grammar
->
insert
(
$this
,
$values
);
$sql
=
$this
->
grammar
->
insert
(
$this
,
$values
);
$this
->
connection
->
statement
(
$sql
,
array_values
(
$values
));
$this
->
connection
->
query
(
$sql
,
array_values
(
$values
));
// Some database systems (Postgres) require a sequence name to be
// Some database systems (Postgres) require a sequence name to be
// given when retrieving the auto-incrementing ID, so we'll pass
// given when retrieving the auto-incrementing ID, so we'll pass
...
@@ -797,7 +797,7 @@ class Query {
...
@@ -797,7 +797,7 @@ class Query {
$sql
=
$this
->
grammar
->
update
(
$this
,
$values
);
$sql
=
$this
->
grammar
->
update
(
$this
,
$values
);
return
$this
->
connection
->
update
(
$sql
,
$bindings
);
return
$this
->
connection
->
query
(
$sql
,
$bindings
);
}
}
/**
/**
...
@@ -820,7 +820,7 @@ class Query {
...
@@ -820,7 +820,7 @@ class Query {
$sql
=
$this
->
grammar
->
delete
(
$this
);
$sql
=
$this
->
grammar
->
delete
(
$this
);
return
$this
->
connection
->
delete
(
$sql
,
$this
->
bindings
);
return
$this
->
connection
->
query
(
$sql
,
$this
->
bindings
);
}
}
/**
/**
...
...
laravel/database/schema.php
View file @
faa2eec3
...
@@ -89,7 +89,7 @@ class Schema {
...
@@ -89,7 +89,7 @@ class Schema {
// needs multiple queries to complete.
// needs multiple queries to complete.
foreach
((
array
)
$statements
as
$statement
)
foreach
((
array
)
$statements
as
$statement
)
{
{
$connection
->
statement
(
$statement
);
$connection
->
query
(
$statement
);
}
}
}
}
}
}
...
...
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