我试图生成一个多维数组,每个子数组代表我想插入我的数据库的行.原因是我可以使用CodeIgniters batch_insert函数将每行添加到数据库中.
我试图在循环中创建每个子数组并将其插入到多维数组中.Google建议使用array_merge,但在使用下面的代码在多维数组上使用'print_r'后,只显示最后一个子数组.
这是我的代码:
$allplayerdata = array(); //M-D container array
for ($i = 1; $i <= 11; $i++)
{
$playerdata = array(
'player_id' => $this->input->post('player' . $i),
'goals' => $this->input->post('playergoals' . $i),
'player_num' => $i,
'fixture_id' => $this->input->post('fixture_id')
);
//Merge each player row into same array to allow for batch insert
$allplayerdata = array_merge($allplayerdata, $playerdata);
}
print_r($allplayerdata);
Run Code Online (Sandbox Code Playgroud)
谁能发现我哪里出错?感谢帮助!
使用 Laravel Socailite 连接到 Google API,我恢复了正常连接,但是此访问不会返回刷新令牌,因此我的连接超时。
$scopes = [
'https://www.googleapis.com/auth/webmasters',
'https://www.googleapis.com/auth/webmasters.readonly',
'https://www.googleapis.com/auth/analytics.readonly',
'https://www.googleapis.com/auth/userinfo.profile',
'https://www.googleapis.com/auth/userinfo.email',
];
$parameters = ['access_type' => 'offline'];
return Socialite::driver('google')->scopes($scopes)->with($parameters)->redirect();
Run Code Online (Sandbox Code Playgroud)
如何取回刷新令牌?
php google-api laravel google-api-php-client laravel-socialite
我的代码中有一个for循环.我在这部分代码上没有改变任何东西大约5-6天,我从来没有遇到任何问题.
从昨天起我试图重新加载我的代码,它总是给我这个错误:
Maximum execution time of 30 seconds exceeded - in LogController.php line 270
Run Code Online (Sandbox Code Playgroud)
好吧,我无法解释为什么,但也许有人可以看一下.
这是我在第270行的代码.
$topten_sites = [];
for ($i = 0; $i <= count($sites_array); $i++) {
if ($i < 10) { // this is 270
$topten_sites[] = $sites_array[$i];
}
}
$topten_sites = collect($topten_sites)->sortByDesc('number')->all();
Run Code Online (Sandbox Code Playgroud)
正如我所说,它工作得很好,为什么它给我一个错误?如果我取消注释这些行以及包含$ topten_sites数组的每个其他行,代码将再次运行.
好的,所以我尝试使用 SHA 512 验证密码,但无论如何它仍然返回 false,就像哈希检查不正确一样。
注册时生成哈希
$hashed = password_hash(hash('sha512', $password), PASSWORD_DEFAULT);
Run Code Online (Sandbox Code Playgroud)
并验证(登录时)我使用简单
public function isValidLogin($username, $password) {
$sql = $this->connect();
$sql->real_escape_string($username);
$sql->real_escape_string($password);
$res = $sql->query("SELECT password FROM users WHERE name='".$username."'");
if ($res->num_rows >= 1) {
while($row = $res->fetch_assoc()) {
if (password_verify(hash('sha512', $password), $row['password'])) {
return true;
}
}
}
return false;
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试以正确的方式键入函数,该函数为该函数应用函数名称和参数。之后应用它并返回结果。这里的代码:
const sum = (a: number, b: number) => a + b
const concat = (a: string, b: string, c: string) => a + b + c
const funs = {
sum,
concat
}
type Keys = 'sum' | 'concat'
type Args<T> = T extends (...args: infer R) => any ? R : never
type Sum = Args<typeof sum>
type Concat = Args<typeof concat>
function apply<K extends Keys>(funKey: K, ...args: Args<typeof funs[K]>) {
// here I get the error 'An …Run Code Online (Sandbox Code Playgroud) typescript typescript-generics typescript-typings typescript-types
我在程序中使用os.Pipes(),但是由于某种原因,每次我尝试从中写入或读取数据时,它都会给出错误的文件描述符错误。
我做错了什么吗?
下面是代码
package main
import (
"fmt"
"os"
)
func main() {
writer, reader, err := os.Pipe()
if err != nil {
fmt.Println(err)
}
_,err= writer.Write([]byte("hello"))
if err != nil {
fmt.Println(err)
}
var data []byte
_, err = reader.Read(data)
if err != nil {
fmt.Println(err)
}
fmt.Println(string(data))
}
Run Code Online (Sandbox Code Playgroud)
输出:写入| 0:无效的参数读取| 1:无效的参数
我有一个基于我需要更改href和链接文本的页面的导航,但无法让它工作.
这就是我需要的
<?php
if ($thisPage=="Index-EN" || "Index-IT") {
?>
<li><a href="#" class="scroll-link" data-id="about"><?php echo MENU_ABOUT ?>AAA</a></li>
<li><a href="#" class="scroll-link" data-id="gallery"><?php echo MENU_GALLERY ?></a></li>
<li><a href="<?php echo MENU_CONTACTS_LINK_HOME ?>"><?php echo MENU_CONTACTS ?></a></li>
<?php
} else {
?>
<li><a href="index.php#about" data-id="about"><?php echo MENU_ABOUT ?>BBB</a></li>
<li><a href="index.php#gallery" data-id="gallery"><?php echo MENU_GALLERY ?></a></li>
<li><a href="<?php echo MENU_CONTACTS_LINK ?>"><?php echo MENU_CONTACTS ?></a></li>
<?php
}
?>
Run Code Online (Sandbox Code Playgroud)
这就是我尝试过的,我知道这是错误的,因为导航消失了
<?php
if ($thisPage=="Index-EN" || "Index-IT") {
echo '
<li><a href="#" class="scroll-link" data-id="about">' . MENU_ABOUT . 'AAA</a></li>
<li><a href="#" class="scroll-link" data-id="gallery">' …Run Code Online (Sandbox Code Playgroud) php ×5
arrays ×1
codeigniter ×1
for-loop ×1
go ×1
google-api ×1
hash ×1
html ×1
laravel ×1
sha512 ×1
typescript ×1