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
Show 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
<?php
/*
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
...
@@ -24,7 +22,7 @@ namespace Doctrine\DBAL\Driver\Mysqli;
...
@@ -24,7 +22,7 @@ namespace Doctrine\DBAL\Driver\Mysqli;
use
Doctrine\DBAL\Driver
as
DriverInterface
;
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
class
Driver
implements
DriverInterface
{
{
...
...
lib/Doctrine/DBAL/Driver/Mysqli/MysqliConnection.php
View file @
88d16346
...
@@ -24,7 +24,7 @@ namespace Doctrine\DBAL\Driver\Mysqli;
...
@@ -24,7 +24,7 @@ namespace Doctrine\DBAL\Driver\Mysqli;
use
Doctrine\DBAL\Driver\Connection
as
ConnectionInterface
;
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
class
MysqliConnection
implements
ConnectionInterface
{
{
...
@@ -40,8 +40,7 @@ class MysqliConnection implements ConnectionInterface
...
@@ -40,8 +40,7 @@ class MysqliConnection implements ConnectionInterface
$this
->
_conn
=
new
\mysqli
(
$params
[
'host'
],
$username
,
$password
,
$params
[
'dbname'
],
$port
,
$socket
);
$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'
]);
$this
->
_conn
->
set_charset
(
$params
[
'charset'
]);
}
}
}
}
...
...
lib/Doctrine/DBAL/Driver/Mysqli/MysqliException.php
View file @
88d16346
...
@@ -22,7 +22,7 @@
...
@@ -22,7 +22,7 @@
namespace
Doctrine\DBAL\Driver\Mysqli
;
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
class
MysqliException
extends
\Exception
{}
{}
lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php
View file @
88d16346
<?php
<?php
/*
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
...
@@ -21,13 +19,12 @@
...
@@ -21,13 +19,12 @@
namespace
Doctrine\DBAL\Driver\Mysqli
;
namespace
Doctrine\DBAL\Driver\Mysqli
;
use
Doctrine\DBAL\Driver\Statement
as
StatementInterface
;
use
PDO
;
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
(
private
static
$_paramTypeMap
=
array
(
PDO
::
PARAM_STR
=>
's'
,
PDO
::
PARAM_STR
=>
's'
,
...
@@ -149,8 +146,7 @@ class MysqliStatement implements \IteratorAggregate, StatementInterface
...
@@ -149,8 +146,7 @@ class MysqliStatement implements \IteratorAggregate, StatementInterface
if
(
null
===
$this
->
_columnNames
)
{
if
(
null
===
$this
->
_columnNames
)
{
$meta
=
$this
->
_stmt
->
result_metadata
();
$meta
=
$this
->
_stmt
->
result_metadata
();
if
(
false
!==
$meta
)
if
(
false
!==
$meta
)
{
{
$columnNames
=
array
();
$columnNames
=
array
();
foreach
(
$meta
->
fetch_fields
()
as
$col
)
{
foreach
(
$meta
->
fetch_fields
()
as
$col
)
{
$columnNames
[]
=
$col
->
name
;
$columnNames
[]
=
$col
->
name
;
...
@@ -161,25 +157,20 @@ class MysqliStatement implements \IteratorAggregate, StatementInterface
...
@@ -161,25 +157,20 @@ class MysqliStatement implements \IteratorAggregate, StatementInterface
$this
->
_rowBindedValues
=
array_fill
(
0
,
count
(
$columnNames
),
NULL
);
$this
->
_rowBindedValues
=
array_fill
(
0
,
count
(
$columnNames
),
NULL
);
$refs
=
array
();
$refs
=
array
();
foreach
(
$this
->
_rowBindedValues
as
$key
=>
&
$value
)
foreach
(
$this
->
_rowBindedValues
as
$key
=>
&
$value
)
{
{
$refs
[
$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
);
throw
new
MysqliException
(
$this
->
_stmt
->
error
,
$this
->
_stmt
->
errno
);
}
}
}
}
else
{
else
{
$this
->
_columnNames
=
false
;
$this
->
_columnNames
=
false
;
}
}
}
}
// We have a result.
// We have a result.
if
(
false
!==
$this
->
_columnNames
)
if
(
false
!==
$this
->
_columnNames
)
{
{
$this
->
_stmt
->
store_result
();
$this
->
_stmt
->
store_result
();
}
}
return
true
;
return
true
;
...
@@ -212,15 +203,13 @@ class MysqliStatement implements \IteratorAggregate, StatementInterface
...
@@ -212,15 +203,13 @@ class MysqliStatement implements \IteratorAggregate, StatementInterface
if
(
true
===
$ret
)
{
if
(
true
===
$ret
)
{
$values
=
array
();
$values
=
array
();
// Aint there another way to copy values ?
foreach
(
$this
->
_rowBindedValues
as
$v
)
{
foreach
(
$this
->
_rowBindedValues
as
$v
)
{
// Mysqli converts them to a scalar type it can fit in. Tests dont expect that.
// Mysqli converts them to a scalar type it can fit in. Tests dont expect that.
$values
[]
=
null
===
$v
?
null
:
(
string
)
$v
;
$values
[]
=
null
===
$v
?
null
:
(
string
)
$v
;
}
}
return
$values
;
return
$values
;
}
else
{
return
$ret
;
}
}
return
$ret
;
}
}
/**
/**
...
@@ -229,8 +218,10 @@ class MysqliStatement implements \IteratorAggregate, StatementInterface
...
@@ -229,8 +218,10 @@ class MysqliStatement implements \IteratorAggregate, StatementInterface
public
function
fetch
(
$fetchStyle
=
null
)
public
function
fetch
(
$fetchStyle
=
null
)
{
{
$values
=
$this
->
_fetch
();
$values
=
$this
->
_fetch
();
if
(
!
$values
)
{
if
(
null
===
$values
)
{
return
$values
;
// false or null
return
null
;
}
elseif
(
false
===
$values
)
{
throw
new
MysqliException
(
$this
->
_stmt
->
error
,
$this
->
_stmt
->
errno
);
}
}
$fetchStyle
=
$fetchStyle
?:
$this
->
_defaultFetchStyle
;
$fetchStyle
=
$fetchStyle
?:
$this
->
_defaultFetchStyle
;
...
@@ -249,7 +240,7 @@ class MysqliStatement implements \IteratorAggregate, StatementInterface
...
@@ -249,7 +240,7 @@ class MysqliStatement implements \IteratorAggregate, StatementInterface
return
$ret
;
return
$ret
;
default
:
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
...
@@ -259,7 +250,7 @@ class MysqliStatement implements \IteratorAggregate, StatementInterface
public
function
fetchAll
(
$fetchStyle
=
\PDO
::
FETCH_BOTH
)
public
function
fetchAll
(
$fetchStyle
=
\PDO
::
FETCH_BOTH
)
{
{
$a
=
array
();
$a
=
array
();
while
((
$row
=
$this
->
fetch
(
$fetchStyle
))
!=
null
)
{
while
((
$row
=
$this
->
fetch
(
$fetchStyle
))
!=
=
null
)
{
$a
[]
=
$row
;
$a
[]
=
$row
;
}
}
return
$a
;
return
$a
;
...
@@ -271,8 +262,10 @@ class MysqliStatement implements \IteratorAggregate, StatementInterface
...
@@ -271,8 +262,10 @@ class MysqliStatement implements \IteratorAggregate, StatementInterface
public
function
fetchColumn
(
$columnIndex
=
0
)
public
function
fetchColumn
(
$columnIndex
=
0
)
{
{
$values
=
$this
->
_fetch
();
$values
=
$this
->
_fetch
();
if
(
!
$values
)
{
if
(
null
===
$values
)
{
return
false
;
return
null
;
}
elseif
(
false
===
$values
)
{
throw
new
MysqliException
(
$this
->
_stmt
->
error
,
$this
->
_stmt
->
errno
);
}
}
return
$values
[
$columnIndex
];
return
$values
[
$columnIndex
];
}
}
...
@@ -309,9 +302,8 @@ class MysqliStatement implements \IteratorAggregate, StatementInterface
...
@@ -309,9 +302,8 @@ class MysqliStatement implements \IteratorAggregate, StatementInterface
{
{
if
(
false
===
$this
->
_columnNames
)
{
if
(
false
===
$this
->
_columnNames
)
{
return
$this
->
_stmt
->
affected_rows
;
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