Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
PHP-MySQLi-Database-Class
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
Kulya
PHP-MySQLi-Database-Class
Commits
f4925894
Commit
f4925894
authored
Oct 13, 2010
by
Jeffrey Way
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More bug fixes
parent
94c81556
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
9 deletions
+10
-9
MysqlDb.php
MysqlDb.php
+10
-9
No files found.
MysqlDb.php
View file @
f4925894
...
@@ -37,7 +37,7 @@ class MysqlDB {
...
@@ -37,7 +37,7 @@ class MysqlDB {
*/
*/
public
function
get
(
$tableName
,
$numRows
=
NULL
)
public
function
get
(
$tableName
,
$numRows
=
NULL
)
{
{
$this
->
_crudType
=
'read'
;
$this
->
_query
=
"SELECT * FROM
$tableName
"
;
$this
->
_query
=
"SELECT * FROM
$tableName
"
;
$stmt
=
$this
->
_buildQuery
(
$numRows
);
$stmt
=
$this
->
_buildQuery
(
$numRows
);
$stmt
->
execute
();
$stmt
->
execute
();
...
@@ -55,6 +55,7 @@ class MysqlDB {
...
@@ -55,6 +55,7 @@ class MysqlDB {
*/
*/
public
function
insert
(
$tableName
,
$insertData
)
public
function
insert
(
$tableName
,
$insertData
)
{
{
$this
->
_crudType
=
'insert'
;
$this
->
_query
=
"INSERT into
$tableName
"
;
$this
->
_query
=
"INSERT into
$tableName
"
;
$stmt
=
$this
->
_buildQuery
(
NULL
,
$insertData
);
$stmt
=
$this
->
_buildQuery
(
NULL
,
$insertData
);
$stmt
->
execute
();
$stmt
->
execute
();
...
@@ -72,6 +73,7 @@ class MysqlDB {
...
@@ -72,6 +73,7 @@ class MysqlDB {
*/
*/
public
function
update
(
$tableName
,
$tableData
)
public
function
update
(
$tableName
,
$tableData
)
{
{
$this
->
_crudType
=
'update'
;
$this
->
_query
=
"UPDATE
$tableName
SET "
;
$this
->
_query
=
"UPDATE
$tableName
SET "
;
$stmt
=
$this
->
_buildQuery
(
NULL
,
$tableData
);
$stmt
=
$this
->
_buildQuery
(
NULL
,
$tableData
);
$stmt
->
execute
();
$stmt
->
execute
();
...
@@ -85,7 +87,9 @@ class MysqlDB {
...
@@ -85,7 +87,9 @@ class MysqlDB {
* @param string $tableName The name of the database table to work with.
* @param string $tableName The name of the database table to work with.
* @return boolean Indicates success. 0 or 1.
* @return boolean Indicates success. 0 or 1.
*/
*/
public
function
delete
(
$tableName
)
{
public
function
delete
(
$tableName
)
{
$this
->
_crudType
=
'delete'
;
$this
->
_query
=
"DELETE FROM
$tableName
"
;
$this
->
_query
=
"DELETE FROM
$tableName
"
;
$stmt
=
$this
->
_buildQuery
();
$stmt
=
$this
->
_buildQuery
();
...
@@ -162,9 +166,7 @@ class MysqlDB {
...
@@ -162,9 +166,7 @@ class MysqlDB {
// and create the SQL query, accordingly.
// and create the SQL query, accordingly.
if
(
$hasTableData
)
{
if
(
$hasTableData
)
{
$i
=
1
;
$i
=
1
;
$pos
=
strpos
(
$this
->
_query
,
'UPDATE'
);
if
(
$this
->
_crudType
==
'update'
)
{
if
(
$pos
!==
false
)
{
$this
->
_crudType
=
'update'
;
foreach
(
$tableData
as
$prop
=>
$value
)
{
foreach
(
$tableData
as
$prop
=>
$value
)
{
// determines what data type the item is, for binding purposes.
// determines what data type the item is, for binding purposes.
$this
->
_paramTypeList
.=
$this
->
_determineType
(
$value
);
$this
->
_paramTypeList
.=
$this
->
_determineType
(
$value
);
...
@@ -186,10 +188,8 @@ class MysqlDB {
...
@@ -186,10 +188,8 @@ class MysqlDB {
}
}
}
}
// Determine if is INSERT query
// Determine if is INSERT query
if
(
$hasTableData
&&
!
isset
(
$this
->
_crudType
))
{
if
(
$hasTableData
&&
$this
->
_crudType
==
'insert'
)
{
$pos
=
strpos
(
$this
->
_query
,
'INSERT'
);
if
(
$this
->
_crudType
==
'insert'
)
{
if
(
$pos
!==
false
)
{
//is insert statement
$keys
=
array_keys
(
$tableData
);
$keys
=
array_keys
(
$tableData
);
$values
=
array_values
(
$tableData
);
$values
=
array_values
(
$tableData
);
$num
=
count
(
$keys
);
$num
=
count
(
$keys
);
...
@@ -270,6 +270,7 @@ class MysqlDB {
...
@@ -270,6 +270,7 @@ class MysqlDB {
*/
*/
protected
function
_prepareQuery
()
protected
function
_prepareQuery
()
{
{
echo
$this
->
_query
;
if
(
!
$stmt
=
$this
->
_mysql
->
prepare
(
$this
->
_query
))
{
if
(
!
$stmt
=
$this
->
_mysql
->
prepare
(
$this
->
_query
))
{
trigger_error
(
"Problem preparing query"
,
E_USER_ERROR
);
trigger_error
(
"Problem preparing query"
,
E_USER_ERROR
);
}
}
...
...
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