Пример #1
0
 public function testConnect()
 {
     $env_vars = array('vertex_vertica_odbc_dsn', 'vertex_vertica_user', 'vertex_vertica_password');
     foreach ($env_vars as $env_var) {
         $this->assertNotFalse(getenv($env_var), "Environment variable {$env_var} is not set.");
     }
     $vertex = new \Kiva\Silverpop_Connector\VertexClient();
     $count = $vertex->fetchData('select count(1) as row_count from email_blacklist');
     $this->assertNotFalse($count);
     $row_count = $count[0]['row_count'];
     $this->assertTrue($row_count && is_numeric($row_count) && $row_count > 0);
 }
Пример #2
0
<?php

require_once './vendor/autoload.php';
const LOCAL_UPLOAD_DIR = './upload';
const LOCAL_SQL_DIR = './src/sql';
if (!is_dir(LOCAL_UPLOAD_DIR)) {
    mkdir(LOCAL_UPLOAD_DIR);
}
$logger = new \Kiva\Silverpop_Connector\Logger();
$logger->info('Starting Silverpop Upload job');
#Connect to vertica
$vertex = new \Kiva\Silverpop_Connector\VertexClient();
$upload_files = array();
#get sql queries
$sql_files = scandir(LOCAL_SQL_DIR);
#get file args if they exist
$sql_files_to_use = array();
foreach ($argv as $key => $val) {
    if ($key === 0) {
        continue;
    }
    array_push($sql_files_to_use, $val);
}
#pull each query into a local file
foreach ($sql_files as $sql_file) {
    $sql_basename = basename($sql_file, '.sql');
    $is_hidden_file = substr($sql_basename, 0, 1) === '.';
    if (!$is_hidden_file) {
        try {
            $query = file_get_contents(LOCAL_SQL_DIR . '/' . $sql_file);
            if (empty($sql_files_to_use) || in_array($sql_basename, $sql_files_to_use)) {