CodeIgniter Forums
Close connection - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: Close connection (/showthread.php?tid=71473)

Pages: 1 2


Close connection - omid_student - 08-17-2018

Hi
Is it important for close connection after query?
Example
$res = $this->db->query('')->result_array();
$this->db->close();

Also i have other question
How do i can delete cache only for special query?
at the moment we can delete all cache


RE: Close connection - kaitenz - 08-17-2018

(08-17-2018, 05:07 AM)omid_student Wrote: Hi
Is it important for close connection after query?
Example
$res = $this->db->query('')->result_array();
$this->db->close();

Also i have other question
How do i can delete cache only for special query?
at the moment we can delete all cache

AFAIK, Query builder automatically close the database after use (correct me if I'm wrong)

For special queries, assign your special query to a variable:
PHP Code:
$special_query $this->db->query(); 

Then if you want to use 
PHP Code:
$this->db->flush_cache(); 

You can still use your special query:
PHP Code:
$special_query->result(); 

But I didn't try this before (but I use query caching a lot), so try it for yourself.


RE: Close connection - omid_student - 08-17-2018

(08-17-2018, 05:19 AM)XtreemDeveloper Wrote: You can use this line after your query

$this->output->delete_cache('path');
Can i use output cache for database?
But my cache is for database
For each query,codeigniter save file in special folder
Actually in segment country/list folder save all caches file
And i need delete special file
Example
$this->db->query('select * from data where id = 1'); => file name is 12asf1af124123123123
$this->db->query('select * from data where id = 2'); => file name is 12asf1afsdfsdfdsf323123

I need delete 12asf1afsdfsdfdsf323123 file not all files in folder


RE: Close connection - kaitenz - 08-17-2018

(08-17-2018, 05:19 AM)XtreemDeveloper Wrote: You can use this line after your query

$this->output->delete_cache('path');

Dude, your reply is completely irrelevant to the question. 

That's for output, not for queries. You're just spamming your website.


RE: Close connection - omid_student - 08-17-2018

(08-17-2018, 05:28 AM)kaitenz Wrote:
(08-17-2018, 05:19 AM)XtreemDeveloper Wrote: You can use this line after your query

$this->output->delete_cache('path');

Dude, your reply is completely irrelevant to the question. 

That's for output, not for queries. You're just spamming your website.

Sorry i was be confused
My big problem is cache query


RE: Close connection - kaitenz - 08-17-2018

(08-17-2018, 05:30 AM)omid_student Wrote:
(08-17-2018, 05:28 AM)kaitenz Wrote:
(08-17-2018, 05:19 AM)XtreemDeveloper Wrote: You can use this line after your query

$this->output->delete_cache('path');

Dude, your reply is completely irrelevant to the question. 

That's for output, not for queries. You're just spamming your website.

Sorry i was be confused
My big problem is cache query

No, that comment is not for you. It's for XtreemDeveloper.

Have you tried my answer? Hope it helps you.


RE: Close connection - omid_student - 08-17-2018

(08-17-2018, 05:32 AM)kaitenz Wrote:
(08-17-2018, 05:30 AM)omid_student Wrote:
(08-17-2018, 05:28 AM)kaitenz Wrote:
(08-17-2018, 05:19 AM)XtreemDeveloper Wrote: You can use this line after your query

$this->output->delete_cache('path');

Dude, your reply is completely irrelevant to the question. 

That's for output, not for queries. You're just spamming your website.

Sorry i was be confused
My big problem is cache query

No, that comment is not for you. It's for XtreemDeveloper.

Have you tried my answer? Hope it helps you.

Thank you
Yes i tried it but it is looklike database caching
It means that output cache delete all files in folder no special file
Actually i want to remove special file
Please let me more explain :
I have many hotels that user search it for each hotel
And i cache their ,example cache query for hotel id with 1 or 2 or 3
Now maybe i change hotel name with id 3
So i force codeigniter to remove cache for hotel id 3 file not all files
Maybe?


RE: Close connection - InsiteFX - 08-17-2018

If you autoload any of the libraries they are left loaded,
they only close if you load them in a method call.


RE: Close connection - omid_student - 08-17-2018

(08-17-2018, 11:24 AM)InsiteFX Wrote: If you autoload any of the libraries they are left loaded,
they only close if you load them in a method call.

yes it is autoload
Thanks about it
And what is your suggest for delete special record cache (Database)?


RE: Close connection - InsiteFX - 08-18-2018

You would need to keep track of your query caches maybe in an array etc;

Then you could just grab it from your array etc; Then delete that special one.