Exemplo n.º 1
0
 function sql_exec($sql, $limit = 0, $offset = 0)
 {
     $this->_sql_result = null;
     if ($this->is_debug_enabled()) {
         debug::write_debug($sql);
         debug::accumulator_start('db', 'sql_exec');
     }
     $this->_sql_result = $this->_sql_exec_operation($sql, $limit, $offset);
     if ($this->is_debug_enabled()) {
         debug::accumulator_stop('db', 'sql_exec');
     }
     if (!$this->_sql_result) {
         error($this->_sql_exec_error($sql), __FILE__ . ' : ' . __LINE__ . ' : ' . __FUNCTION__);
     }
     return $this->_sql_result;
 }
Exemplo n.º 2
0
 function sql_exec($sql, $limit = 0, $offset = 0)
 {
     $this->_sql_result = null;
     if ($this->is_debug_enabled()) {
         $md5 = md5($sql);
         if (isset($this->_executed_sql[$md5])) {
             $this->_executed_sql[$md5]['times']++;
             debug::write_debug('same SQL query at: ' . '<a href=#' . $this->_executed_sql[$md5]['pos'] . '><b>' . $this->_executed_sql[$md5]['pos'] . '</b></a>' . ' already executed for ' . $this->_executed_sql[$md5]['times'] . ' times');
         } else {
             debug::write_debug($sql);
             $this->_executed_sql[$md5] = array('pos' => debug::sizeof(), 'times' => 0);
         }
         debug::accumulator_start('db', 'sql_exec');
     }
     $this->_sql_result = $this->_sql_exec_operation($sql, $limit, $offset);
     if ($this->is_debug_enabled()) {
         debug::accumulator_stop('db', 'sql_exec');
     }
     if (!$this->_sql_result) {
         error($this->_sql_exec_error($sql), __FILE__ . ' : ' . __LINE__ . ' : ' . __FUNCTION__);
     }
     return $this->_sql_result;
 }
Exemplo n.º 3
0
  function sql_exec($sql, $limit=0, $offset=0)
  {
    $this->_sql_result = null;

    if($this->is_debug_enabled())
    {
      $debug_sql = preg_replace("~(\n|\r|\t)~", '', $sql);
      $debug_sql = preg_replace("~\s+~", ' ', $debug_sql);
      $md5 = md5($debug_sql);

      if(isset($this->_executed_sql[$md5]))
      {
        $this->_executed_sql[$md5]['times']++;

        debug :: write_debug("same SQL at: #" . $this->_executed_sql[$md5]['pos'] .
          ' already executed for ' . $this->_executed_sql[$md5]['times'] . ' times'
        );
      }
      else
      {
        $pos = sizeof($this->_executed_sql);
        debug :: write_debug('#' . $pos . ' ' . $debug_sql);
        $this->_executed_sql[$md5] = array('pos' => $pos, 'times' => 0);
      }

      debug :: accumulator_start('db', 'sql_exec');
    }

    $this->_sql_result = $this->_sql_exec_operation($sql, $limit, $offset);

    if($this->is_debug_enabled())
      debug :: accumulator_stop('db', 'sql_exec');

    if (!$this->_sql_result)
    {
      error(
        $this->_sql_exec_error($sql),
        __FILE__ . ' : ' . __LINE__ . ' : ' .  __FUNCTION__);
    }

    return $this->_sql_result;
  }