Example #1
0
 public static function reInitData()
 {
     static::cleanUp();
     $totalCnt = 0;
     $offset = 0;
     $stat = array();
     while (true) {
         $res = Location\Name\LocationTable::getList(array('select' => array('NAME', 'LOCATION_ID', 'TID' => 'LOCATION.TYPE_ID'), 'filter' => array('=LOCATION.TYPE.CODE' => array('CITY', 'VILLAGE', 'STREET'), '=LANGUAGE_ID' => 'ru'), 'limit' => self::STEP_SIZE, 'offset' => $offset));
         $cnt = 0;
         while ($item = $res->fetch()) {
             if (strlen($item['NAME'])) {
                 $words = static::parseQuery($item['NAME']);
                 foreach ($words as $k => &$word) {
                     try {
                         static::add(array('WORD' => $word, 'TYPE_ID' => $item['TID'], 'LOCATION_ID' => $item['LOCATION_ID']));
                     } catch (\Bitrix\Main\DB\SqlQueryException $e) {
                         // duplicate or smth
                     }
                 }
                 $stat['W_' . count($words)] += 1;
                 //_print_r($words);
             }
             $cnt++;
             $totalCnt++;
         }
         if (!$cnt) {
             break;
         }
         $offset += self::STEP_SIZE;
     }
     _print_r('Total: ' . $totalCnt);
     _print_r($stat);
 }
Example #2
0
foreach ($data as $key => $val) {
    $cur_symbol = $val['Symbol'];
    array_push($symbols_array[$cur_symbol], $val);
}
_print_r($symbols_array, false);
//-------------------------------------
//-------------------------------------
// find the open, heigh, low, & closing of the day
$data_day = array();
foreach ($symbols_array as $key => $val) {
    $heigh_array = array();
    $low_array = array();
    foreach ($val as $kk => $vv) {
        $heigh_array[] = $vv['Heigh'];
        $low_array[] = $vv['Low'];
    }
    // _print_r($heigh_array,false);
    // _print_r($low_array,false);
    $date = explode(' ', $val[0]['Datetime']);
    $data_day[] = array('Symbol' => $val[0]['Symbol'], 'Open' => $val[0]['Open'], 'Heigh' => max($heigh_array), 'Low' => min($low_array), 'Closing' => $val[count($val) - 1]['Closing'], 'Datetime' => $val[0]['Datetime'], 'Range_start' => $date[0] . ' ' . $config['range_start'], 'Range_end' => $date[0] . ' ' . $config['range_end']);
}
_print_r($data_day, false);
//----------------------------------
//---------------------------------------------------
// insert into day table
$db->insert_day($config['db']['day_table'], $data_day);
//---------------------------------------------------
//---------------------------------------------------
// delete data from the day table according to the settings
$db->del($config['db']['day_table'], $config['day_table_range']);
//---------------------------------------------------
Example #3
0
    $cur_symbol = $val['Symbol'];
    array_push($symbols_array[$cur_symbol], $val);
}
// _print_r($symbols_array,false);
//-------------------------------------
//-------------------------------------
// find the open, heigh, low, & closing of the range
$data_range = array();
foreach ($symbols_array as $key => $val) {
    $heigh_array = array();
    $low_array = array();
    foreach ($val as $kk => $vv) {
        $heigh_array[] = $vv['Heigh'];
        $low_array[] = $vv['Low'];
    }
    // _print_r($heigh_array,false);
    // _print_r($low_array,false);
    $date = explode(' ', $val[0]['Datetime']);
    $data_range[] = array('Symbol' => $val[0]['Symbol'], 'Open' => $val[0]['Open'], 'Heigh' => max($heigh_array), 'Low' => min($low_array), 'Closing' => $val[count($val) - 1]['Closing'], 'Datetime' => $val[0]['Datetime'], 'Range_start' => $date[0] . ' ' . $config['range_start'], 'Range_end' => $date[0] . ' ' . $config['range_end']);
}
_print_r($data_range, false);
// die;
//----------------------------------
//---------------------------------------------------
// insert into day table
$db->insert_range($config['db']['range_table'], $data_range);
//---------------------------------------------------
//---------------------------------------------------
// delete data from the range table according to the settings
$db->del($config['db']['range_table'], $config['range_table_range']);
//---------------------------------------------------
Example #4
0
 public function aws_log($id)
 {
     $aws_logs = $this->ranking_data_model->get_('aws_logs', array('id' => $id));
     $aws_log = reset($aws_logs);
     if (!empty($aws_log->params)) {
         $aws_log->params = json_decode($aws_log->params);
     }
     if (!empty($aws_log->result)) {
         $aws_log->result = json_decode($aws_log->result);
         if (!empty($aws_log->result->Messages)) {
             foreach ($aws_log->result->Messages as &$message) {
                 if (!empty($message->Body)) {
                     if ($body_decoded = base64_decode($message->Body)) {
                         $message->Body = $body_decoded;
                     }
                 }
             }
         }
     }
     _print_r($aws_log);
 }
Example #5
0
<?php

require_once 'Database.php';
function _print_r($var)
{
    echo '<pre>';
    print_r($var);
    echo '</pre>';
}
//$users = Database::getInstance()->select('users' , array('users=>''username' , 'password'), array('username' , '=' , 'alex'))->_print_r();
//$users = Database::getInstance()->insert('users' , array( 'username' => 'ishan',
//										 				  'password' => 'password'));
//$users = Database::getInstance()->select('users')->_print_r();
$users = Database::getInstance()->select_multiple(array('users', 'info'), array('*'), array('users' => 'id', '=', 'info' => 'userid'));
//$users = Database::getInstance()->select('users' , array('*') , array('username' , '=' , 'ishan') );
//$name = $users->username;
_print_r($users->results());
//how to use
//use query
//query('select * from ? where ? = ?' , array('foo' , 'foo1' , 'bar1'));
// insert into foo ('foo1' , 'foo2') values('bar1' , 'bar2')
//insert('users' , array('foo1' => 'bar1' , 'foo2' => 'bar2'));
// delete from foo where foo1 = bar1
//delete('foo' , array('foo1' , '=' , 'bar1'))
//update foo set foo1 = bar1 where foo2 = bar2
//update('foo' , array('foo1' => 'bar1') , array('foo2' ,'=' , 'bar2'))