php中有什么方法可以计算两组日期之间的星期五(或指定的任何其他日期)的数量吗?我是通过像这样的sql来实现的,现在我想直接在php中实现,我在谷歌上搜索了一下,发现只有几天和几周的时间,其他的却没有一周的时间。
我尝试使用 codeigniter 使用 SMTP 发送邮件。但出现以下问题。即使我的凭据是正确的,并且在我在 Gmail 中打开时工作正常。之后我收到以下消息。
220 smtp.gmail.com ESMTP uo6sm2505144wjc.1 - gsmtp
hello: 250-smtp.gmail.com at your service, [198.58.84.54]
250-SIZE 35882577
250-8BITMIME
250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN XOAUTH
250-ENHANCEDSTATUSCODES
250-PIPELINING
250-CHUNKING
250 SMTPUTF8
Failed to authenticate password. Error: 534-5.7.14 Please log in via your web browser and 534-5.7.14 then try again. 534-5.7.14 Learn more at 534 5.7.14 https://support.google.com/mail/answer/78754 uo6sm2505144wjc.1 - gsmtp
from: 530-5.5.1 Authentication Required. Learn more at
530 5.5.1 https://support.google.com/mail/answer/14257 uo6sm2505144wjc.1 - gsmtp
The following SMTP error was encountered: …Run Code Online (Sandbox Code Playgroud) 我CodeIgniter需要插入预约信息。现在的问题是每个预约都可能有更多的相关服务。因此,为了解决这个问题,我想为一个约会创建多行,例如:
预约详情
服务:剪裁,颜色
您如何看到有两个关联的服务,因此在我的数据库中我将有两行,如下所示:
id| name | service
10 appointment cut
10 appointment | color
Run Code Online (Sandbox Code Playgroud)
现在,我的实现中不再有剪切和颜色,而是有一个数字,因为我有另一个包含所有服务详细信息的表。这是我的代码,允许我在表中插入约会:
$appuntamento = $appointment;
unset($appuntamento['id_services']);
foreach($appointment['id_services'] as $id)
{
$appuntamento['id_services'] = $id;
if(!$this->db->insert('ea_appointments', $appuntamento))
{
throw new Exception('Error.');
}
$insert_id = intval($this->db->insert_id());
}
return $insert_id;
Run Code Online (Sandbox Code Playgroud)
在此函数中,我传递参数appointment,并在 appuntamento 对象中克隆该appointment对象,因为我需要循环遍历appointment.
事实上,表中是否应该有那么多相同日期的行,就像关联的服务数量一样?我正在执行取消设置,id_services因为它是一个数组,正如我所说,我需要为每个关联的服务插入相同的约会。
因此,在 foreach 中,我设置了id_servicesappuntamento 变量的索引。所以我插入对象,结构是这样的:
INSERT INTO `ea_appointments` (`id_users_provider`, `start_datetime`, `end_datetime`,
`notes`, `is_unavailable`, `id_users_customer`, `book_datetime`, `hash`, `id_services`)
VALUES ('85', '2015-11-14 22:00:00', '2015-11-14 22:00:00', '', 0, …Run Code Online (Sandbox Code Playgroud) 当我加载数据库时出现此错误:
遇到 PHP 错误 严重性:通知消息:未初始化的字符串偏移量:0 文件名:mysqli/mysqli_driver.php 行号:120 回溯:文件:/home1/learnio3/public_html/application/controllers/Reading.php 行:9 功能:数据库
Run Code Online (Sandbox Code Playgroud)File: /home1/learnio3/public_html/index.php Line: 315 Function: require_once
public function __construct() {
parent::__construct();
$this->load->database();
$this->load->helper('url');
}
Run Code Online (Sandbox Code Playgroud)
数据库.php
$active_group = 'default';
$query_builder = TRUE;
$db['default'] = array(
'dsn' => '',
'hostname' => '',
'username' => 'learnio3_bram',
'password' => 'xxxxxxx',
'database' => 'learnio3_book',
'dbdriver' => 'mysqli',
'dbprefix' => '',
'pconnect' => FALSE,
'db_debug' => (ENVIRONMENT !== 'production'),
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 codeigniter 中的 mysql 检查表是否存在,以及该表中的记录是否可用。这是我尝试过的功能,但是 id 不起作用。
function isRowExist($table, $id)
{
if(mysqli_query("DESCRIBE {$table}")) {
$query = $this->db->query("SELECT * FROM {$table} WHERE id = '{$id}'");
}
return $query->num_rows();
}
Run Code Online (Sandbox Code Playgroud)
任何帮助,将不胜感激。
我正在使用 Codeigniter 将多表单输入数据插入到数据库中。我有这个帖子输入数组:
Array
(
[subject_id] => Array
(
[0] => 1
[1] => 1
)
[question] => Array
(
[0] => test
[1] => test2
)
[option1] => Array
(
[0] => test
[1] => test2
) )
Run Code Online (Sandbox Code Playgroud)
我不明白如何转换此数组以插入如何使用插入批处理插入此数组。
$this->db->insert_batch('mytable', $data);
Run Code Online (Sandbox Code Playgroud)
这是我用于发布数据的表单代码:
<form method="post">
<input type="text" name="subject_id[]" >
<input type="text" name="question[]" >
<input type="text" name="record[]" >
// Down side Part is appended when user want to add more question
<input type="text" name="subject_id[]" >
<input type="text" name="question[]" >
<input type="text" …Run Code Online (Sandbox Code Playgroud) 在我的应用程序中,我希望用户进行单点登录。当他离开应用程序时。顾名思义,只有当用户关闭当前浏览器选项卡或浏览器窗口或浏览器引用按钮时才会发生这种情况。可以使用 JavaScript OnUnload 事件。但问题是这个事件发生在
我已经处理了前 3 个案例,但无法检测到浏览器刷新和后退/前进按钮单击。你们有人实现过这样的功能吗,请帮助我?
提前致谢!!!
你好,我得到了这个结果
遇到 PHP 错误
严重性:错误
消息:无法使用 CI_DB_mysqli_result 类型的对象作为数组
文件名:controllers/Threads.php
线路数量:48
回溯:
这是我在控制器中的代码
// category
public function threadsview($slug) {
// get threads category
$data['item'] = $this->threads_model->getThreadsCategory($slug);
$data['title'] = $data['item']['catname'];
$data['desc'] = '';
$this->load->view('themes/default/header', $data);
$this->load->view('threads/threadsview', $data);
$this->load->view('themes/default/footer');
}
Run Code Online (Sandbox Code Playgroud)
以及我的模型中的代码
//get threads categories by slug
public function getThreadsCategory($slug) {
$this->db->order_by('id','asc');
$this->db->where('slug',$slug);
$query = $this->db->get('threads_cat');
return $query;
}
Run Code Online (Sandbox Code Playgroud)
错误来自于这段代码
$data['title'] = $data['item']['catname'];
Run Code Online (Sandbox Code Playgroud)
我希望有人能帮助我解决这个问题。
所以我的控制器上有这个功能来检查用户是否登录,但当用户未登录时它不会重定向到登录页面
public function __construct()
{
if(session()->get('logged_in') !== true)
{
redirect('login');
}
}
Run Code Online (Sandbox Code Playgroud)
有人有解决方案吗?或者我应该对每个功能进行会话检查?喜欢
public function examplefunction()
{
if(session()->get('logged_in') !== true)
{
redirect('login');
}
//run other codes
}
Run Code Online (Sandbox Code Playgroud) 当我使用以下代码创建令牌时,我尝试在 CI4 中使用 JWT 创建一个 Restful api:
$key = getenv('TOKEN_SECRET');
$payload = array(
"iat" => 1356999524,
"nbf" => 1357000000,
"uid" => $user['id'],
"email" => $user['email']
);
$token = JWT::encode($payload, $key);
Run Code Online (Sandbox Code Playgroud)
为什么我会收到错误:
预计有 3 个参数。找到 2
codeigniter ×10
php ×8
arrays ×1
date ×1
javascript ×1
jquery ×1
jwt ×1
mysql ×1
smtp ×1
sql ×1