鍍金池/ 問答/ PHP問答
呆萌傻 回答

php經(jīng)驗(yàn)少的,TP 難些, CMS 容易些。
有php經(jīng)驗(yàn) CMS 經(jīng)驗(yàn)少的 TP 容易些, CMS難些。
要二次開發(fā)以及深入了解 CMS 系統(tǒng)源碼,比TP難較多。

先審題:

題主是想把相關(guān)的數(shù)據(jù)庫配置信息通過表單存儲在一個數(shù)據(jù)庫中,然后通過讀取數(shù)據(jù)庫中數(shù)據(jù)配置信息,然后去實(shí)現(xiàn)訪問不同數(shù)據(jù)庫的功能,而不是把所有的數(shù)據(jù)庫配置信息預(yù)先配置在 config/database.php 中。

如果沒有理解錯的話,再來解題:

Laravel 數(shù)據(jù)庫信息存儲到數(shù)據(jù)庫中

數(shù)據(jù)庫配置信息存儲在數(shù)據(jù)庫中,只要按照 Laravel 的數(shù)據(jù)庫配置要求去存儲即可,這個隨意題主怎么存儲,在 config/database.php 中已經(jīng)有了各類數(shù)據(jù)庫配置的示例。

多數(shù)據(jù)庫連接

在官方文檔中有說明用法 $users = DB::connection('foo')->select(...); 看官方文檔即可。

把數(shù)據(jù)庫中存儲的數(shù)據(jù)配置信息設(shè)置到 Laravel 的 config 中去

  1. 首先編寫自己的 ServiceProvider
  2. ServiceProvider boot 方法中添加如下代碼。
    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
        //1. get your database config from database.
        //Your code.
        
        
        //2. set database info to laravel database config.
        $this->app['config']->set('database.connections.testing', [
            'driver' => 'mysql',
            'database' => ...
        ]);

    }        

沒有親自去實(shí)戰(zhàn),提供一種思路,請題主自行實(shí)驗(yàn)。

陌上花 回答

Promise.then(res=>return res.json()).then(res=>console.log(res));
第一次then的時候轉(zhuǎn)JOSN格式,第二次的then的時候就可以得到這個對象了

抱緊我 回答

2make 是用來編譯的,它從Makefile中讀取指令,然后編譯。

3make install是用來安裝的,它也從Makefile中讀取指令,安裝到指定的位置。

膽怯 回答

thinkphp5 現(xiàn)在也有類似laravel的數(shù)據(jù)庫遷移工具

具體參考文檔:https://www.kancloud.cn/manua...

倉庫地址:https://github.com/top-think/...

青瓷 回答

前段時間剛做了微信公眾號的客服 第三方接入。
他的功能是讓你的即時聊天系統(tǒng)可以和微信的客服系統(tǒng)進(jìn)行溝通。
所以,如果你要接入微信的客服系統(tǒng),你首先要有一個即時聊天的功能。

情殺 回答

哥們 解決了嗎?

亮瞎她 回答

顯示的時候在 pri_name 前面添加 level個空格或者其它符號 就可以了

青裙 回答

設(shè)置心跳檢測時間試試
array(

'heartbeat_idle_time' => 600,
'heartbeat_check_interval' => 60,

);
https://wiki.swoole.com/wiki/...

刮刮樂 回答

textarea有maxlength屬性的,
<textarea maxlength="number">
把number設(shè)大點(diǎn)試試。

薔薇花 回答

因?yàn)樵趃etAll2中. for循環(huán)里面:

$str =$str.$array[$i];

你對str進(jìn)行了重新賦值,而第一個str沒有被重新賦值,只是單純拼了個新的傳進(jìn)去.

把第二個改成這樣也是正常的:

function getAll2($array,$str=null){    
    $length = count($array);
    if($length<=1){
        echo $str.$array[0].PHP_EOL;
    }else{
        for($i=0;$i<$length;$i++){
            $temp = $array;
            array_splice($temp,$i,1);
            $str2 =$str.$array[$i];
            getAll2($temp,$str2); 
        }
    }
}
寫榮 回答
<?php

sscanf($str, '%sMicroMessenger/%d', $filter_info, $version);


神曲 回答

clipboard.png
用svg做的,不過是直線,沒有限定一對一,是多對多的關(guān)系

孤星 回答

1.方案一:

div {
  width: 25%;
  height: 0;
  padding-bottom: 12.5%;
  background: blue;
}

2.方案二,如果元素的寬度是視口寬度的25%,則可以用如下方法

div {
    width: 25vw;
    height: 12.5vw;
}

https://www.zhihu.com/questio...

filter函數(shù)就行吧。
var arr = ['a', 'b', 'c', ''];
if (arr.filter(item => item).length > 3) { ... }

話寡 回答

通過查看源碼發(fā)現(xiàn),主動依附關(guān)聯(lián)是使用主鍵的。

在 Illuminate\Database\EloquentRelations\BelongsToMany 中的create()方法如下:

public function create(array $attributes = [], array $joining = [], $touch = true)
{
    $instance = $this->related->newInstance($attributes);

    // Once we save the related model, we need to attach it to the base model via
    // through intermediate table so we'll use the existing "attach" method to
    // accomplish this which will insert the record and any more attributes.
    $instance->save(['touch' => false]);

    $this->attach($instance->getKey(), $joining, $touch);

    return $instance;
}

其中,$instance->getKey()就是獲取主鍵的值。

因此,要實(shí)現(xiàn)通過非主鍵key來關(guān)聯(lián),分兩步走,先手工創(chuàng)建Attachment記錄,然后attach($attachmentKey)。要想一步到位它就是使用主鍵id來關(guān)聯(lián)。

一般來說,一個表的外鍵使用另一個表的主鍵是比較主流的做法,Laravel這么做也有一定道理。最終我決定也通過Attachment中的id來關(guān)聯(lián)算了,不使用非主鍵key來關(guān)聯(lián)。

厭遇 回答

<input type="checkbox" checked="checked" style="color:red;">

判斷 checked 這個屬性是否存在

撿肥皂 回答

php里變量使用前并不需要聲明,對于傳地址的輸出變量來說,如果不使用初值的話,初始化也是沒有必要的.

參見
http://php.net/manual/en/lang...