Skip to content

Commit 7d8bc3a

Browse files
author
Radovan Janjic
committed
Update
1 parent ca06ddd commit 7d8bc3a

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

MySQL_wrapper.class.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ class MySQL_wrapper {
164164
* @param string $database - MySQL Database
165165
* @return - singleton instance
166166
*/
167-
public static function getInstance($server = NULL, $username = NULL, $password = NULL, $database = NULL){
167+
public static function getInstance($server = NULL, $username = NULL, $password = NULL, $database = NULL) {
168168
$md5 = md5(implode('|', array($server, $username, $password, $database)));
169169
if (empty(self::$instance[$md5])) {
170170
self::$instance[$md5] = new MySQL_wrapper($server, $username, $password, $database);
@@ -327,7 +327,7 @@ public function query($sql) {
327327
$sql = str_replace($p['search'], $p['replace'], $sql);
328328
unset($l, $p);
329329
}
330-
if($this->logQueries) $start = $this->getMicrotime();
330+
if ($this->logQueries) $start = $this->getMicrotime();
331331
$this->query = $this->call('query', $sql) or $this->error("Query fail: " . $sql);
332332
$this->affected = $this->call('affected_rows');
333333
if ($this->query && $this->logQueries) $this->log('QUERY', "EXEC -> " . number_format($this->getMicrotime() - $start, 8) . " -> " . $sql);
@@ -569,7 +569,7 @@ public function importUpdateCSV2Table($file, $table, $delimiter = ',', $enclosur
569569
// Remove auto_increment if exists
570570
$change = array();
571571
$this->query("SHOW COLUMNS FROM `{$tmp_name}` WHERE `Key` NOT LIKE '';");
572-
if($this->affected > 0){
572+
if ($this->affected > 0) {
573573
while ($row = $this->fetchArray()) {
574574
$change[$row['Field']] = "CHANGE `{$row['Field']}` `{$row['Field']}` {$row['Type']}";
575575
}
@@ -923,7 +923,7 @@ public function query2XML($query, $rootElementName, $childElementName, $file = N
923923
// The child will take the name of the result column name
924924
$record .= "\t\t<{$fieldName}>";
925925
// Set empty columns with NULL and escape XML entities
926-
if(!empty($row->$fieldName)) {
926+
if (!empty($row->$fieldName)) {
927927
$record .= htmlspecialchars($row->$fieldName, ENT_XML1);
928928
} else {
929929
$record .= NULL;
@@ -1079,7 +1079,7 @@ public function initTableRevision($table) {
10791079
// Remove auto_increment if exists
10801080
$change = array();
10811081
$this->query("SHOW COLUMNS FROM `{$rev_table}` WHERE `Key` NOT LIKE '' OR `Default` IS NOT NULL;");
1082-
if($this->affected > 0){
1082+
if ($this->affected > 0) {
10831083
while ($row = $this->fetchArray()) {
10841084
$change[$row['Field']] = "CHANGE `{$row['Field']}` `{$row['Field']}` {$row['Type']} DEFAULT " . (($row['Extra']) ? 0 : 'NULL');
10851085
}
@@ -1092,7 +1092,7 @@ public function initTableRevision($table) {
10921092
// Remove indexes from revision table
10931093
$this->query("SHOW INDEXES FROM `{$rev_table}`;");
10941094
$drop = array();
1095-
if($this->affected > 0){
1095+
if ($this->affected > 0) {
10961096
while ($row = $this->fetchArray()) {
10971097
$drop[] = "DROP INDEX `{$row['Key_name']}`";
10981098
}

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ $db->connect();
383383
$count = $db->countRows('table');
384384

385385
// Count with condition
386-
$count2 = $db->countRows('table', "`date` = '".date("Y-m-d")."'");
386+
$count2 = $db->countRows('table', "`date` = '" . date("Y-m-d") . "'");
387387

388388
// ...
389389
echo "Count all: {$count}, Count today: {$count2}";

example.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
3535
3636
// Some dummy data, uncomment to insert
37-
if(!$db->countRows('table') > 0)
37+
if (!$db->countRows('table') > 0)
3838
$db->query("INSERT INTO `table` (`id`, `firstname`, `surname`, `email`, `date`) VALUES
3939
(1, 'Radovan', 'Janjic', '', '2012-11-04'),
4040
(2, 'Radovan', 'Janjic', '[email protected]', '2012-11-04'),

0 commit comments

Comments
 (0)