TIP: Use Markdown or, <pre> for multi line code blocks / <code> for inline code.
These forums are read-only and for archival purposes only!
Please join our new forums at discourse.kohanaframework.org
DB query builder & memory
  • v3.2.2

    protected function _check_url($url){
            $path = str_replace($this->scheme . '://' . $this->host, "", $url);
            $cnt = DB::select(array('COUNT("*")', 'cnt'))
                    ->where('lang_id', '=', $this->lang)
                    ->and_where('host', '=', $this->scheme.'://'.$this->host)
                    ->and_where('url', '=', $path)
                    ->get('cnt'); unset($path);
            return !(boolean) $cnt;

    memory used (for example more than 50 iterations) 20 Mb and more

    protected function _check_url($url){
            $path = str_replace($this->scheme . '://' . $this->host, "", $url);
            $cnt = mysql_query("SELECT COUNT(*) AS cnt FROM `".$this->_db['config']['table_prefix']."indexer_pages` WHERE `lang_id`='".addslashes($this->lang)."' AND `host`='".addslashes($this->scheme.'://'.$this->host)."' AND `url`='".addslashes($path)."' LIMIT 1", $this->_db['connection']);
            $cnt = mysql_fetch_row($cnt);
            $cnt = $cnt[0];
            return !(boolean) $cnt;

    memory used 3-5Mb

  • Using PHP >= 5.3?

  • php v 5.3.17

  • I had the same issue, selecting and inserting with the query builder inside a bucle was blowing up the memory. So I solved it using direct queries to the database. I want to know if there is an instruction to flush query builder memory, or something to avoid this. Thanks.

  • Disable database profiling in your config file.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion