Question

Im using CodeIgniters DBforge to use my database.

Im trying to convert a plain PHP script to CodeIgniter and im having some trouble with changing the SQL to dbforge.

I have the following SQL code

CREATE TABLE `message2_recips` (
  `mid` int(10) unsigned NOT NULL,
  `seq` int(10) unsigned NOT NULL,
  `uid` int(10) unsigned NOT NULL,
  `status` char(1) NOT NULL default 'N',
  KEY `m2r1` USING BTREE (`mid`,`status`),
  KEY `m2r2` USING BTREE (`uid`,`status`)
) ENGINE=InnoDB;

Everything works fine except when i get to the 2 key values at the bottom.

Everything i have tried doesnt seem to work including,

$this->dbforge->add_key(array('mid', 'status'));
$this->dbforge->add_key(array('uid', 'status'));

Any help translating this would be greatly appreciated, i cant seem to find any way to input this using dbforge, which brings my project to a complete standstill

Thanks.

Was it helpful?

Solution

Impossible to do (currently) via DB Forge - it doesn't support additional options for table keys. You can only achieve that by adding them afterwards with raw SQL queries.

OTHER TIPS

There is a bug in DB_forge.php

You need to remove is_array condition to enable multiple keys (in mysql driver there is function to convert the array key to multiple key).

DBForge.php:101

Remove:

    if (is_array($key))
    {
        foreach ($key as $one)
        {
            $this->add_key($one, $primary);
        }

        return;
    }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top