Welcome Guest, Not a member yet? Register   Sign In
DBForge creating an index
#1

[eluser]msteudel[/eluser]
Is there a way with DBForge to create an index when you are creating a table? I'm working on a EE module and setting up the install/uninstall part of the module. I want to be able to add indexes when the user installs the module.
#2

[eluser]jrtashjian[/eluser]
In CodeIgniter you can use:
Code:
$this->dbforge->add_key('field');

I'm not sure about the ExpressionEngine side of things, probably very similar. Maybe like:
Code:
$this->EE->dbforge->add_key('field');
#3

[eluser]Developer13[/eluser]
Might want to post your question in the EE forums?
#4

[eluser]InsiteFX[/eluser]
I do not think that you can do it with DBForge.

Use DBForge to create your database and build your fields and keys then create the table.

Then you can run this query to add your index to the table.

But this will work.

1) Change your_index_name to the name of the index you want.
2) Change table_name to your table name.
3) Change field_name to your table field name.

Code:
$sql = "CREATE INDEX your_index_name ON table_name(field_name)";
$this->db->query($sql);

InsiteFX
#5

[eluser]Cambo[/eluser]
[quote author="jrtashjian" date="1289977561"]In CodeIgniter you can use:
Code:
$this->dbforge->add_key('field');

I'm not sure about the ExpressionEngine side of things, probably very similar. Maybe like:
Code:
$this->EE->dbforge->add_key('field');
[/quote]

Adding a Key is not the same as adding an Index. :-)


[quote author="InsiteFX" date="1289997210"]I do not think that you can do it with DBForge.

Use DBForge to create your database and build your fields and keys then create the table.

Then you can run this query to add your index to the table.

Code:
$sql = "CREATE INDEX your_index_name ON table_name(field_name)";
$this->db->query($sql);

InsiteFX[/quote]

This works fine for me. I just place it after the create table call.
Cambo




Theme © iAndrew 2016 - Forum software by © MyBB