<bdo id='ts6Wh'></bdo><ul id='ts6Wh'></ul>
    <tfoot id='ts6Wh'></tfoot>
  • <legend id='ts6Wh'><style id='ts6Wh'><dir id='ts6Wh'><q id='ts6Wh'></q></dir></style></legend>

    1. <small id='ts6Wh'></small><noframes id='ts6Wh'>

      1. <i id='ts6Wh'><tr id='ts6Wh'><dt id='ts6Wh'><q id='ts6Wh'><span id='ts6Wh'><b id='ts6Wh'><form id='ts6Wh'><ins id='ts6Wh'></ins><ul id='ts6Wh'></ul><sub id='ts6Wh'></sub></form><legend id='ts6Wh'></legend><bdo id='ts6Wh'><pre id='ts6Wh'><center id='ts6Wh'></center></pre></bdo></b><th id='ts6Wh'></th></span></q></dt></tr></i><div id='ts6Wh'><tfoot id='ts6Wh'></tfoot><dl id='ts6Wh'><fieldset id='ts6Wh'></fieldset></dl></div>

        Yii 生成没有 Gii 的模型

        Yii generate model without Gii(Yii 生成没有 Gii 的模型)
            <tbody id='L8yp5'></tbody>

          • <bdo id='L8yp5'></bdo><ul id='L8yp5'></ul>
            <legend id='L8yp5'><style id='L8yp5'><dir id='L8yp5'><q id='L8yp5'></q></dir></style></legend>

              <small id='L8yp5'></small><noframes id='L8yp5'>

              <tfoot id='L8yp5'></tfoot>
                <i id='L8yp5'><tr id='L8yp5'><dt id='L8yp5'><q id='L8yp5'><span id='L8yp5'><b id='L8yp5'><form id='L8yp5'><ins id='L8yp5'></ins><ul id='L8yp5'></ul><sub id='L8yp5'></sub></form><legend id='L8yp5'></legend><bdo id='L8yp5'><pre id='L8yp5'><center id='L8yp5'></center></pre></bdo></b><th id='L8yp5'></th></span></q></dt></tr></i><div id='L8yp5'><tfoot id='L8yp5'></tfoot><dl id='L8yp5'><fieldset id='L8yp5'></fieldset></dl></div>

                • 本文介绍了Yii 生成没有 Gii 的模型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我需要在不使用 Gii 的情况下生成模型文件.Yii有什么命令吗?

                  I need to generate a model file without the use of Gii. Are there any command Yii?

                  $table = "myTable";
                  Yii::app()->generateModel($table); // ?
                  

                  推荐答案

                  也许官方已经弃用了,你可以用 Yii 命令行工具

                  Perhaps is officially deprecated, you can generate code with Yii Command Line Tools

                  我已经用 Yii 1.1.17 测试过了.

                  I have tested it with Yii 1.1.17.

                  首先你需要在 protected/commands 上创建一个新文件,例如 NewmodelCommand.php 创建一个新的 yii 命令.我们需要避免使用shell交互工具,在控制器、模型等我们的代码中直接调用命令.为了得到它,我们继承了Yii核心类ModelCommand.这个类最初强迫人们在交互式 shell 上输入.

                  First you need to create a new file on protected/commands called for example NewmodelCommand.php to create a new yii command. We need to avoid to use shell interactive tool and call command directly from our code in controllers, models, etc. To get it, we inherit Yii core class ModelCommand. This class originally force person to type on interactive shell.

                  <?php
                  
                  Yii::import('system.cli.commands.shell.ModelCommand');
                  
                  
                  class NewmodelCommand extends ModelCommand
                  {
                  
                  }
                  

                  仅此而已.您可以将 CLI 中的命令测试到您的操作系统中.在 Linux 中,打开终端并转到 /protected/ 目录并键入:

                  That is all. You can test command from CLI into your operating system. In Linux, open your terminal and go to /protected/ directory and type:

                  ./yiic
                  

                  您将看到如下内容:

                  ...
                  The following commands are available:
                   - message
                   - migrate
                   - newmodel
                   - shell
                   - webapp
                  ...
                  

                  稍微玩一下.再次输入:

                  Play a little with it. Type again:

                  ./yiic newmodel
                  

                  您将看到所有命令帮助和文档.

                  And you will see all command help and documentation.

                  要使用此命令生成模型,您至少需要 model_name 作为第一个参数.命令将使用与数据库表名相同的模型名:

                  To generate a model with this command you need at least model_name as first parameter. Command will use same model name as database table name:

                  ./yiic newmodel MyNewModel
                  

                  如果您有不同的模型和数据库名称:

                  If you have different model and database name:

                  ./yiic newmodel MyNewModel tbl_new_model
                  

                  如果您在使用 yiic、定位/连接数据库等方面遇到问题,请确保在 protected/config/console.php 和 查看所有关于 Yii 控制台应用程序的官方文档.

                  If you have troubles using yiic, locating/connecting your db, etc, make sure to setup properly your console environment on protected/config/console.php and check all official docs about Yii console applications.

                  最后在您的代码中,您可以根据需要使用您的命令:

                  Finally in your code you can use your command as you want:

                  $path = '/full/path/to/protected';
                  $new_model_name = 'MyNewModel';
                  shell_exec( $path . "/./yiic newmodel $new_model_name" );
                  

                  这篇关于Yii 生成没有 Gii 的模型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                  PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                  mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                  Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                  Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                  Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)

                    <i id='AMkzI'><tr id='AMkzI'><dt id='AMkzI'><q id='AMkzI'><span id='AMkzI'><b id='AMkzI'><form id='AMkzI'><ins id='AMkzI'></ins><ul id='AMkzI'></ul><sub id='AMkzI'></sub></form><legend id='AMkzI'></legend><bdo id='AMkzI'><pre id='AMkzI'><center id='AMkzI'></center></pre></bdo></b><th id='AMkzI'></th></span></q></dt></tr></i><div id='AMkzI'><tfoot id='AMkzI'></tfoot><dl id='AMkzI'><fieldset id='AMkzI'></fieldset></dl></div>
                        <tfoot id='AMkzI'></tfoot>
                      1. <legend id='AMkzI'><style id='AMkzI'><dir id='AMkzI'><q id='AMkzI'></q></dir></style></legend>
                          <bdo id='AMkzI'></bdo><ul id='AMkzI'></ul>

                            <tbody id='AMkzI'></tbody>
                        • <small id='AMkzI'></small><noframes id='AMkzI'>