dt614037527
dt614037527
2012-09-05 01:08

有没有执行sql的函数? 具体是CakeSchema生成的sql?

已采纳

Is there a function that executes mysql? Specifically mysql generated by the CakeSchema?

This is an example of the data I want to import:

    $this->Schema = new CakeSchema();
    $Schema = $this->Schema->load();
    $db = ConnectionManager::getDataSource($this->Schema->connection);
    $contents = "

" . $db->createSchema($Schema);
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

1条回答

  • dor65412 dor65412 9年前

    If it's actually MySQL, then just use query()

    $this->MyModel->query("CREATE TABLE ....");
    

    Because it likely doesn't really fit with one of your models, you can always make a "DataFunction" model and tell it to $useTable = false;... then store any/all of these kind of "general" functions there. Then load the model and call your function from whatever action you'd like.

    点赞 评论 复制链接分享