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

          <bdo id='1Skak'></bdo><ul id='1Skak'></ul>

      1. <legend id='1Skak'><style id='1Skak'><dir id='1Skak'><q id='1Skak'></q></dir></style></legend>

        <small id='1Skak'></small><noframes id='1Skak'>

        <tfoot id='1Skak'></tfoot>
      2. 在 Rails4 中将我的数据库从 sqlite3 切换到 mysql 时出现 strftime 错误

        时间:2023-10-26
      3. <i id='mXKXN'><tr id='mXKXN'><dt id='mXKXN'><q id='mXKXN'><span id='mXKXN'><b id='mXKXN'><form id='mXKXN'><ins id='mXKXN'></ins><ul id='mXKXN'></ul><sub id='mXKXN'></sub></form><legend id='mXKXN'></legend><bdo id='mXKXN'><pre id='mXKXN'><center id='mXKXN'></center></pre></bdo></b><th id='mXKXN'></th></span></q></dt></tr></i><div id='mXKXN'><tfoot id='mXKXN'></tfoot><dl id='mXKXN'><fieldset id='mXKXN'></fieldset></dl></div>
          • <bdo id='mXKXN'></bdo><ul id='mXKXN'></ul>
          • <small id='mXKXN'></small><noframes id='mXKXN'>

                <tbody id='mXKXN'></tbody>
              <tfoot id='mXKXN'></tfoot>
                  <legend id='mXKXN'><style id='mXKXN'><dir id='mXKXN'><q id='mXKXN'></q></dir></style></legend>
                • 本文介绍了在 Rails4 中将我的数据库从 sqlite3 切换到 mysql 时出现 strftime 错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  最近我将我的数据库从 sqlite3 更改为 mysql.当我运行我的项目时,我在使用此查询的文件之一中收到此错误.

                  Recently i changed my database from sqlite3 to mysql.When i ran my project i am getting this error in one of the file which is using this query.

                  日期 = 日期.今天 + 1

                  date = Date.today + 1

                  @employees = Employee.where("status = ? AND strftime('%d/%m', date_of_birth) = ?", "Active" , date.strftime('%d/%m')

                  @employees = Employee.where("status = ? AND strftime('%d/%m', date_of_birth) = ?", "Active" , date.strftime('%d/%m')

                  ActionView::Template::Error (Mysql2::Error: FUNCTION hrms_development.strftime does not exist: SELECT COUNT(*) FROM `employees` WHERE (status = 'Active' AND strftime('%d/%m', date_of_birth) = '28/03')):
                      210:             
                      211:               <% date = Date.today %>
                      212:              <% @employees = Employee.where("status = ? AND strftime('%d/%m', date_of_birth) = ?", "Active" , date.strftime('%d/%m')) %>
                      213:             <% if @employees.empty? %>
                      214:              
                      215:             <%else%>
                      216:               <% @employees.each do |e| %>
                    app/views/home/_group_admin.html.erb:213:in `_app_views_home__group_admin_html_erb___2522183600721478262_91627100'
                    app/views/home/index.html.erb:17:in `_app_views_home_index_html_erb__2772204906267359422_86967120'
                  
                  
                  
                  ActionView::Template::Error: Mysql2::Error: FUNCTION hrms_development.strftime does not exist: SELECT COUNT(*) FROM `employees` WHERE (status = 'Active' AND strftime('%d/%m', date_of_birth) = '28/03')

                  推荐答案

                  用简单的替换试试这个,

                  Try this with simply replace,

                  <% @employees = Employee.where("status = ? AND strftime('%d/%m', date_of_birth) = ?", "Active" , date.strftime('%d/%m')) %>
                  

                  <% @employees = Employee.where("status = ? AND DATE_FORMAT(date_of_birth,'%d/%m') = ?", "Active" , date.strftime('%d/%m')) %>
                  

                  这篇关于在 Rails4 中将我的数据库从 sqlite3 切换到 mysql 时出现 strftime 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:尝试使用 mysql2 gem 安装应用程序时出错 下一篇:如何将数据从 ASCII (ISO/IEC 8859-1) 导入 Rails/PGSQL 数据库?

                  相关文章

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

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

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