Skip to content

Commit

Permalink
3.0.0-alpha-20171220
Browse files Browse the repository at this point in the history
  • Loading branch information
benkeen committed Dec 21, 2017
1 parent 34d1dbd commit 9d30d31
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion global/code/Core.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ class Core {
/**
* The release date: YYYYMMDD
*/
private static $releaseDate = "20171218";
private static $releaseDate = "20171220";

/**
* The minimum required PHP version needed to run Form Tools.
Expand Down
23 changes: 23 additions & 0 deletions global/code/Database.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,4 +176,27 @@ public function getMySQLVersion() {
$this->execute();
return $this->fetchColumn();
}

/**
* Convenience method for constructing PDO-friendly insert statements. This is passed a hash of
* column names to values and returns an array with two indexes:
* [0] a comma delimited list of col names, like "mycol1, mycol2, mycol3"
* [1] a command delimited list of placeholders for thos same columns, like ":mycol1, :mycol2, :mycol3"
* @param $hash array of columns => values
* @return array
*/
public function getInsertStatementParams($hash)
{
$col_names = array();
$placeholders = array();
foreach ($hash as $col_name => $value) {
$col_names[] = $col_name;
$placeholders[] = ":{$col_name}";
}

$cols_str = join(", ", $col_names);
$placeholders = join(", ", $placeholders);

return array($cols_str, $placeholders);
}
}

0 comments on commit 9d30d31

Please sign in to comment.