-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Adding truncate() * Adding TruncateStatement for truncate() * Adding example of truncate() * Added drop() method * A bit to fast on the commit. Forgot TABLE IF EXISTS in the getDrop() * Update DropStatement.php * Update TruncateStatement.php * Update Database.php * Fixing CI issues
- Loading branch information
Showing
11 changed files
with
152 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,5 +17,5 @@ abstract class ClauseContainer | |
/** | ||
* @var array | ||
*/ | ||
protected $container = array(); | ||
protected $container = []; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
|
||
namespace FaaPz\PDO\Statement; | ||
|
||
use FaaPz\PDO\Database; | ||
|
||
class DropStatement extends StatementContainer | ||
{ | ||
/** | ||
* Constructor. | ||
* | ||
* @param Database $dbh | ||
* @param $table | ||
*/ | ||
public function __construct(Database $dbh, $table) | ||
{ | ||
parent::__construct($dbh); | ||
|
||
$this->setTable($table); | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function __toString() | ||
{ | ||
if (empty($this->table)) { | ||
trigger_error('No table is set for selection', E_USER_ERROR); | ||
} | ||
|
||
$sql = $this->getDrop().' '.$this->table; | ||
|
||
return $sql; | ||
} | ||
|
||
protected function getDrop() | ||
{ | ||
return 'DROP TABLE IF EXISTS'; | ||
} | ||
|
||
/** | ||
* @return \PDOStatement | ||
*/ | ||
public function execute() | ||
{ | ||
return parent::execute(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
|
||
namespace FaaPz\PDO\Statement; | ||
|
||
use FaaPz\PDO\Database; | ||
|
||
class TruncateStatement extends StatementContainer | ||
{ | ||
/** | ||
* Constructor. | ||
* | ||
* @param Database $dbh | ||
* @param $table | ||
*/ | ||
public function __construct(Database $dbh, $table) | ||
{ | ||
parent::__construct($dbh); | ||
|
||
$this->setTable($table); | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function __toString() | ||
{ | ||
if (empty($this->table)) { | ||
trigger_error('No table is set for selection', E_USER_ERROR); | ||
} | ||
|
||
$sql = $this->getTruncate().' '.$this->table; | ||
|
||
return $sql; | ||
} | ||
|
||
protected function getTruncate() | ||
{ | ||
return 'TRUNCATE'; | ||
} | ||
|
||
/** | ||
* @return \PDOStatement | ||
*/ | ||
public function execute() | ||
{ | ||
return parent::execute(); | ||
} | ||
} |