<legend id='idUcE'><style id='idUcE'><dir id='idUcE'><q id='idUcE'></q></dir></style></legend>

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

  • <small id='idUcE'></small><noframes id='idUcE'>

    • <bdo id='idUcE'></bdo><ul id='idUcE'></ul>
    <tfoot id='idUcE'></tfoot>

      1. 在 Yii 中从 MySQL 获取最后插入的 ID

        Getting Last Inserted Id From MySQL in Yii(在 Yii 中从 MySQL 获取最后插入的 ID)

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

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

                    <tbody id='M7Q8d'></tbody>
                  本文介绍了在 Yii 中从 MySQL 获取最后插入的 ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我想在视图中显示数据库中的最后一个登录ID > _form.php 文件.我在 _form.php 文件中制作了这样的代码

                   

                  <?php echo $form->labelEx($model,'id');?><?php echo Yii::app()->db->getLastInsertId('Form');?><?php echo $form->error($model,'id');?>

                  这里的表格是表格和型号名称.但我仍然得到 ID:0.哪里出错了?

                  解决方案

                  Pekka 的回答对普通有好处.但是如果你想在 Yii Framework 中做那个动作,试试这个:

                  $myModel = 新的 $model;$模型 ->保存(假);echo $model->primaryKey;//打印最后一个 id.

                  或者你也可以试试这个作为通用解决方案:

                  Yii::app()->db->getLastInsertID();

                  最后,我建议您查看这个

                  I want to show the last login id from the database in view > _form.php file.I have made the code in _form.php file like this

                    <div class="row">
                      <?php echo $form->labelEx($model,'id'); ?>
                      <?php echo Yii::app()->db->getLastInsertId('Form');?>
                      <?php echo $form->error($model,'id'); ?>
                    </div>
                  

                  Here Form is the table and the model name.But Still I am getting ID:0.Where is the wrong part?

                  解决方案

                  Pekka's answer is good for common. But if you want to do that action in Yii Framework, try this:

                  $myModel = new $model;
                  $model -> savel(false);
                  echo $model->primaryKey; // Prints the last id.
                  

                  Or you may try this too for general solution:

                  Yii::app()->db->getLastInsertID();
                  

                  Finally, I suggest you to check out this

                  这篇关于在 Yii 中从 MySQL 获取最后插入的 ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  Is PHP or PHP based web framework stateful or stateless?(PHP 或基于 PHP 的 Web 框架是有状态的还是无状态的?)
                  How to parse django style template tags(如何解析 django 样式模板标签)
                  What is a good setup for editing PHP in Emacs?(在 Emacs 中编辑 PHP 的好设置是什么?)
                  How to check whether specified PID is currently running without invoking ps from PHP?(如何在不从 PHP 调用 ps 的情况下检查指定的 PID 当前是否正在运行?)
                  What#39;s the difference between escapeshellarg and escapeshellcmd?(escapeshellarg 和escapeshellcmd 有什么区别?)
                  php in background exec() function(php 后台 exec() 函数)
                  • <bdo id='Opxg0'></bdo><ul id='Opxg0'></ul>

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

                        <tbody id='Opxg0'></tbody>
                      <legend id='Opxg0'><style id='Opxg0'><dir id='Opxg0'><q id='Opxg0'></q></dir></style></legend>

                      1. <tfoot id='Opxg0'></tfoot>

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