CodeIgniter Forums
MySQL - master - slave - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Development (https://forum.codeigniter.com/forumdisplay.php?fid=6)
+--- Forum: CodeIgniter 3.x (https://forum.codeigniter.com/forumdisplay.php?fid=17)
+--- Thread: MySQL - master - slave (/showthread.php?tid=64191)



MySQL - master - slave - consigliere - 01-25-2016

What about master slave support in one of next versions?


RE: MySQL - master - slave - sv3tli0 - 01-25-2016

The relation master - slave is MYSQL setup/configuration task, its not work for the framework..

MYSQL 5.5 Replication Docs > http://dev.mysql.com/doc/refman/5.5/en/replication.html


RE: MySQL - master - slave - consigliere - 01-29-2016

How you can say this?
How will use I in Codeigniter select from slave?


RE: MySQL - master - slave - sv3tli0 - 01-29-2016

What do you understand under Mysql Master - Slave ?

If its a Replication MYSQL service handles this relation.

If its some kind of duplication with 2 instances you need to specify 2nd DB connection inside your app..


RE: MySQL - master - slave - siburny - 01-30-2016

You can install mysqlnd extension and mysqlnd_ms plugin. It will transparently query slave(s) when needed so no code change is required in your app or CI.

More info here: http://php.net/manual/en/book.mysqlnd-ms.php


RE: MySQL - master - slave - consigliere - 02-08-2016

What about that?
(01-30-2016, 08:08 PM)siburny Wrote: You can install mysqlnd extension and mysqlnd_ms plugin. It will transparently query slave(s) when needed so no code change is required in your app or CI.

More info here: http://php.net/manual/en/book.mysqlnd-ms.php
yes I know that but in CI active record there is no option to add comments in query? Is there any option for this?

(01-29-2016, 11:33 PM)sv3tli0 Wrote: What do you understand under Mysql Master - Slave ?

If its a Replication MYSQL service handles this relation.

If its some kind of duplication with 2 instances you need to specify 2nd DB connection inside your app..

you just do not get it


RE: MySQL - master - slave - mwhitney - 02-09-2016

If you need to build your query with Query Builder for some reason, just use $this->db->get_compiled_select() (/_insert()/_update()/_delete()) to get the SQL generated by Query Builder, then pass it to $this->db->query() with your comments. For example:

PHP Code:
$this->db->select('something')->from('somewhere');
$sql $this->db->get_compiled_select();
$this->db->query(sprintf("/*%s*/{$sql}"MYSQLND_MS_MASTER_SWITCH)); 

If that doesn't work for some reason, you can try passing it to simple_query() instead of query().


RE: MySQL - master - slave - consigliere - 02-09-2016

(02-09-2016, 07:33 AM)mwhitney Wrote: If you need to build your query with Query Builder for some reason, just use $this->db->get_compiled_select() (/_insert()/_update()/_delete()) to get the SQL generated by Query Builder, then pass it to $this->db->query() with your comments. For example:

PHP Code:
$this->db->select('something')->from('somewhere');
$sql $this->db->get_compiled_select();
$this->db->query(sprintf("/*%s*/{$sql}"MYSQLND_MS_MASTER_SWITCH)); 

If that doesn't work for some reason, you can try passing it to simple_query() instead of query().

I will try in this way, thanks Smile