Welcome Guest, Not a member yet? Register   Sign In
DataMapper - How to use TEMPORARY tables
#1

[eluser]Genki1[/eluser]
Hi WanWizard,

How would I use MySQL TEMPORARY tables in conjunction with DataMapper? Do I create a DataMapper model for the table?

For example, in CI I would do something like this:

Code:
$sql = "CREATE TEMPORARY TABLE IF NOT EXISTS `accounts_list`
   (`id` INT(8) NOT NULL AUTO_INCREMENT PRIMARY KEY,
   `name` VARCHAR(34) NOT NULL) ENGINE = MyISAM";
$this->db->query($sql);

and then manipulate the table, like this:

Code:
INSERT INTO `accounts_list` ...
and
Code:
SELECT * FROM `account_list` ...

Since the table will exist only for the session, do I create a DataMapper class, like this?

Code:
class Account_list extends DataMapper {
  function __construct($id = NULL)
  {
     parent::__construct($id);
  }
  var $has_one = array();
  var $has_many = array();
}

As always, thank you in advance.




Theme © iAndrew 2016 - Forum software by © MyBB