/**
  * Simple log now text in param to DB table, also record in table time and other data
  * @param string text
  */
 public static function logerr($text)
 {
     if (rad_config::getParam('logger.loginDB', false)) {
         $flush = rad_input::getFlushInput();
         //die(rad_config::getParam('loader_class'));
         $flush['input'] = call_user_func(array(rad_config::getParam('loader_class'), 'getFlushData'));
         $flush = serialize($flush);
         $flush = str_replace('"', '\\"', $flush);
         rad_dbpdo::exec('insert into ' . RAD . 'logger(dt,flush,`text`)values(now(),"' . $flush . '","' . $text . '")');
     }
 }
Exemple #2
0
 /**
  * Delete the user by his u_id field
  *
  * @param integer $u_id
  * @return count deleted records
  */
 public static function deleteUserByID($u_id = null)
 {
     if ($u_id) {
         return rad_dbpdo::exec('delete from ' . RAD . 'users where `u_id`=' . (int) $u_id);
     } else {
         return null;
     }
 }
 /**
  * Executes the SQL with vars
  * @param string $sql
  * @param mixed $vars
  * @example
  * rad_update::execSQL('INSERT INTO @RAD@settings(fldName, fldValue, position, description, rtype, defValue)VALUES("test", "test",100,"description","modules","@value@")', array('value'=>'defValue'));
  * @return rad_update
  */
 public function execSQL($sql, $vars = null)
 {
     if (!empty($vars) and is_array($vars)) {
         foreach ($vars as $key => $value) {
             if (is_scalar($value)) {
                 $sql = str_replace('@' . $key . '@', $value, $sql);
             }
         }
     }
     echo $sql . "\r\n";
     rad_dbpdo::exec($sql);
     if ((int) rad_dbpdo::errorCode()) {
         echo "\r\n" . (int) rad_dbpdo::errorCode();
         print_r(rad_dbpdo::errorInfo());
         echo "\r\n";
     }
     return $this;
 }
Exemple #4
0
 /**
  * Alias for rad_dbpdo::exec($sql)
  *
  * @param $sql string
  *
  * @return integer numrows
  *
  * @access public
  */
 public function exec($sql = null)
 {
     return rad_dbpdo::exec($sql);
 }
Exemple #5
0
 /**
  * Show location tree
  */
 function translations_download()
 {
     //$code, $lang
     $download_mode = strtolower($this->request('mode'));
     // skip, overwrite
     $lang_id = (int) $this->request('lang_id', $this->getContentLangID());
     $url = is_array($this->json_url) ? $this->json_url[$lang_id] : $this->json_url;
     $url .= '?action=translations_all&lang_id=' . $lang_id;
     $result = null;
     if ($this->url_connect($url)) {
         $result = $this->getUrlContent($url);
     }
     $elements = json_decode($result);
     $values = array();
     foreach ($elements as $element) {
         $values[] = "('{$element->lnv_code}', '{$element->lnv_value}', {$lang_id})";
     }
     $query = '';
     switch ($download_mode) {
         case 'overwrite':
             if (count($values) > 0) {
                 $query = "INSERT INTO `rad_langvalues`\n";
                 $query .= "    (`lnv_code`, `lnv_value`, `lnv_lang`)\n";
                 $query .= "VALUES\n";
                 $query .= "    {values}\n";
                 $query .= "ON DUPLICATE KEY UPDATE\n";
                 $query .= "    lnv_value = VALUES(lnv_value)";
                 $query = str_replace('{values}', implode(",\n    ", $values), $query);
             }
             break;
         case 'skip':
             if (count($values) > 0) {
                 $query = "INSERT IGNORE INTO `rad_langvalues`\n";
                 $query .= "    (`lnv_code`, `lnv_value`, `lnv_lang`)\n";
                 $query .= "VALUES\n";
                 $query .= "    {values}";
                 $query = str_replace('{values}', implode(",\n    ", $values), $query);
             }
             break;
     }
     $rows = 0;
     if (strlen($query) > 0) {
         $rows = rad_dbpdo::exec($query);
     }
     echo (int) $rows;
 }