Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support to string-based checksum #205

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
language: php
php:
- '5.5'
- '5.6'
- '7.0'
- hhvm
- nightly

script: make test
4 changes: 2 additions & 2 deletions conf/sample.config.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
* one you want to report on.
*
*/

foreach(glob("conf/datasource_*.inc.php") as $datasource) {
require_once($datasource);
}
Expand Down Expand Up @@ -345,7 +345,7 @@
'callbacks' => array(
'table' => array(
'date' => function ($x) { $type=''; if ( date('N',strtotime($x)) >= 6) { $type = 'weekend'; } return array($x,$type); },
'checksum' => function ($x) { return array(dec2hex($x), ''); }
// 'checksum' => function ($x) { return array(dec2hex($x), ''); }
)
)

Expand Down
3 changes: 2 additions & 1 deletion lib/Anemometer.php
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,8 @@ private function translate_checksum($checksum)
}
else if (preg_match('/^[0-9A-Fa-f]+$/', $checksum))
{
return $this->bchexdec($checksum);
//return $this->bchexdec($checksum);
return $checksum;
}
else if (strlen($checksum) == 0)
{
Expand Down
8 changes: 4 additions & 4 deletions lib/AnemometerModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ public function get_reviewers() {
*/
public function checksum_exists($checksum) {
$checksum_field_name = $this->get_field_name('checksum');
$query = "SELECT `{$checksum_field_name}` FROM `{$this->fact_table}` WHERE `{$checksum_field_name}`=" . $this->mysqli->real_escape_string($checksum);
$query = "SELECT `{$checksum_field_name}` FROM `{$this->fact_table}` WHERE `{$checksum_field_name}`='" . $this->mysqli->real_escape_string($checksum). "'";
$result = $this->mysqli->query($query);
check_mysql_error($result, $this->mysqli);
if ($result->num_rows) {
Expand Down Expand Up @@ -227,7 +227,7 @@ function ($x, $y) use ($mysqli) {
}, array_keys($fields), array_values($fields)
)
);
$sql .= " WHERE `{$checksum_field_name}`=" . $this->mysqli->real_escape_string($checksum);
$sql .= " WHERE `{$checksum_field_name}`='" . $this->mysqli->real_escape_string($checksum) . "'";
$res = $this->mysqli->query($sql);
// @todo ... fix this by making it a local method
check_mysql_error($res, $this->mysqli);
Expand All @@ -241,7 +241,7 @@ function ($x, $y) use ($mysqli) {
*/
public function get_query_by_checksum($checksum) {
$checksum_field_name = $this->get_field_name('checksum');
$result = $this->mysqli->query("SELECT * FROM `{$this->fact_table}` WHERE `{$checksum_field_name}`={$checksum}");
$result = $this->mysqli->query("SELECT * FROM `{$this->fact_table}` WHERE `{$checksum_field_name}`='{$checksum}'");
check_mysql_error($result, $this->mysqli);
if ($row = $result->fetch_assoc()) {
return $row;
Expand All @@ -265,7 +265,7 @@ public function get_query_samples($checksum, $limit = 1, $offset = 0) {
{
$table = $this->fact_table;
}
$sql = "SELECT * FROM `{$table}` WHERE `{$checksum_field_name}`={$checksum} ORDER BY `{$time_field_name}` DESC LIMIT {$limit} OFFSET {$offset}";
$sql = "SELECT * FROM `{$table}` WHERE `{$checksum_field_name}`='{$checksum}' ORDER BY `{$time_field_name}` DESC LIMIT {$limit} OFFSET {$offset}";
return $this->mysqli->query($sql);
}

Expand Down