Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
doctrine-dbal
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
Tomáš Trávníček
doctrine-dbal
Commits
88d16346
Commit
88d16346
authored
Nov 10, 2011
by
Kim Hemsø Rasmussen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed some of the things Stof pointed out.
parent
ed584565
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
34 deletions
+23
-34
Driver.php
lib/Doctrine/DBAL/Driver/Mysqli/Driver.php
+1
-3
MysqliConnection.php
lib/Doctrine/DBAL/Driver/Mysqli/MysqliConnection.php
+2
-3
MysqliException.php
lib/Doctrine/DBAL/Driver/Mysqli/MysqliException.php
+1
-1
MysqliStatement.php
lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php
+19
-27
No files found.
lib/Doctrine/DBAL/Driver/Mysqli/Driver.php
View file @
88d16346
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
...
...
@@ -24,7 +22,7 @@ namespace Doctrine\DBAL\Driver\Mysqli;
use
Doctrine\DBAL\Driver
as
DriverInterface
;
/**
* @author Kim He
n
sø Rasmussen <kimhemsoe@gmail.com>
* @author Kim He
m
sø Rasmussen <kimhemsoe@gmail.com>
*/
class
Driver
implements
DriverInterface
{
...
...
lib/Doctrine/DBAL/Driver/Mysqli/MysqliConnection.php
View file @
88d16346
...
...
@@ -24,7 +24,7 @@ namespace Doctrine\DBAL\Driver\Mysqli;
use
Doctrine\DBAL\Driver\Connection
as
ConnectionInterface
;
/**
* @author Kim He
n
sø Rasmussen <kimhemsoe@gmail.com>
* @author Kim He
m
sø Rasmussen <kimhemsoe@gmail.com>
*/
class
MysqliConnection
implements
ConnectionInterface
{
...
...
@@ -40,8 +40,7 @@ class MysqliConnection implements ConnectionInterface
$this
->
_conn
=
new
\mysqli
(
$params
[
'host'
],
$username
,
$password
,
$params
[
'dbname'
],
$port
,
$socket
);
if
(
isset
(
$params
[
'charset'
]))
{
if
(
isset
(
$params
[
'charset'
]))
{
$this
->
_conn
->
set_charset
(
$params
[
'charset'
]);
}
}
...
...
lib/Doctrine/DBAL/Driver/Mysqli/MysqliException.php
View file @
88d16346
...
...
@@ -22,7 +22,7 @@
namespace
Doctrine\DBAL\Driver\Mysqli
;
/**
* @author Kim He
n
sø Rasmussen <kimhemsoe@gmail.com>
* @author Kim He
m
sø Rasmussen <kimhemsoe@gmail.com>
*/
class
MysqliException
extends
\Exception
{}
lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php
View file @
88d16346
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
...
...
@@ -21,13 +19,12 @@
namespace
Doctrine\DBAL\Driver\Mysqli
;
use
Doctrine\DBAL\Driver\Statement
as
StatementInterface
;
use
PDO
;
/**
* @author Kim He
n
sø Rasmussen <kimhemsoe@gmail.com>
* @author Kim He
m
sø Rasmussen <kimhemsoe@gmail.com>
*/
class
MysqliStatement
implements
\IteratorAggregate
,
StatementInterface
class
MysqliStatement
implements
\IteratorAggregate
,
\Doctrine\DBAL\Driver\Statement
{
private
static
$_paramTypeMap
=
array
(
PDO
::
PARAM_STR
=>
's'
,
...
...
@@ -149,8 +146,7 @@ class MysqliStatement implements \IteratorAggregate, StatementInterface
if
(
null
===
$this
->
_columnNames
)
{
$meta
=
$this
->
_stmt
->
result_metadata
();
if
(
false
!==
$meta
)
{
if
(
false
!==
$meta
)
{
$columnNames
=
array
();
foreach
(
$meta
->
fetch_fields
()
as
$col
)
{
$columnNames
[]
=
$col
->
name
;
...
...
@@ -161,25 +157,20 @@ class MysqliStatement implements \IteratorAggregate, StatementInterface
$this
->
_rowBindedValues
=
array_fill
(
0
,
count
(
$columnNames
),
NULL
);
$refs
=
array
();
foreach
(
$this
->
_rowBindedValues
as
$key
=>
&
$value
)
{
foreach
(
$this
->
_rowBindedValues
as
$key
=>
&
$value
)
{
$refs
[
$key
]
=&
$value
;
}
if
(
!
call_user_func_array
(
array
(
$this
->
_stmt
,
'bind_result'
),
$refs
))
{
if
(
!
call_user_func_array
(
array
(
$this
->
_stmt
,
'bind_result'
),
$refs
))
{
throw
new
MysqliException
(
$this
->
_stmt
->
error
,
$this
->
_stmt
->
errno
);
}
}
else
{
}
else
{
$this
->
_columnNames
=
false
;
}
}
// We have a result.
if
(
false
!==
$this
->
_columnNames
)
{
if
(
false
!==
$this
->
_columnNames
)
{
$this
->
_stmt
->
store_result
();
}
return
true
;
...
...
@@ -212,15 +203,13 @@ class MysqliStatement implements \IteratorAggregate, StatementInterface
if
(
true
===
$ret
)
{
$values
=
array
();
// Aint there another way to copy values ?
foreach
(
$this
->
_rowBindedValues
as
$v
)
{
// Mysqli converts them to a scalar type it can fit in. Tests dont expect that.
$values
[]
=
null
===
$v
?
null
:
(
string
)
$v
;
}
return
$values
;
}
else
{
return
$ret
;
}
return
$ret
;
}
/**
...
...
@@ -229,8 +218,10 @@ class MysqliStatement implements \IteratorAggregate, StatementInterface
public
function
fetch
(
$fetchStyle
=
null
)
{
$values
=
$this
->
_fetch
();
if
(
!
$values
)
{
return
$values
;
// false or null
if
(
null
===
$values
)
{
return
null
;
}
elseif
(
false
===
$values
)
{
throw
new
MysqliException
(
$this
->
_stmt
->
error
,
$this
->
_stmt
->
errno
);
}
$fetchStyle
=
$fetchStyle
?:
$this
->
_defaultFetchStyle
;
...
...
@@ -249,7 +240,7 @@ class MysqliStatement implements \IteratorAggregate, StatementInterface
return
$ret
;
default
:
throw
new
MysqliException
(
sprintf
(
"Unknown fetch type '%s'"
,
$fetchStyle
)
);
throw
new
MysqliException
(
"Unknown fetch type '
{
$fetchStyle
}
'"
);
}
}
...
...
@@ -259,7 +250,7 @@ class MysqliStatement implements \IteratorAggregate, StatementInterface
public
function
fetchAll
(
$fetchStyle
=
\PDO
::
FETCH_BOTH
)
{
$a
=
array
();
while
((
$row
=
$this
->
fetch
(
$fetchStyle
))
!=
null
)
{
while
((
$row
=
$this
->
fetch
(
$fetchStyle
))
!=
=
null
)
{
$a
[]
=
$row
;
}
return
$a
;
...
...
@@ -271,8 +262,10 @@ class MysqliStatement implements \IteratorAggregate, StatementInterface
public
function
fetchColumn
(
$columnIndex
=
0
)
{
$values
=
$this
->
_fetch
();
if
(
!
$values
)
{
return
false
;
if
(
null
===
$values
)
{
return
null
;
}
elseif
(
false
===
$values
)
{
throw
new
MysqliException
(
$this
->
_stmt
->
error
,
$this
->
_stmt
->
errno
);
}
return
$values
[
$columnIndex
];
}
...
...
@@ -309,9 +302,8 @@ class MysqliStatement implements \IteratorAggregate, StatementInterface
{
if
(
false
===
$this
->
_columnNames
)
{
return
$this
->
_stmt
->
affected_rows
;
}
else
{
return
$this
->
_stmt
->
num_rows
;
}
return
$this
->
_stmt
->
num_rows
;
}
/**
...
...
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