FATAL ERROR未捕获错误:无法使用字符串键解压缩数组
我知道我可以简单地运行该方法fetch()两次并通过['q'],['bind']但我正在尝试使用new ...来解压缩值.我想传递这样的值:
(string) SQL, (Array) Bind Values
Run Code Online (Sandbox Code Playgroud)
但我认为它试图解包绑定值数组以及方法中的响应数组fetch().是否可以解压缩这个数组(看起来像这样:)
array(2) {
["q"]=> string(7) "example"
["bind"]=> array(1) {
["example"]=> string(3) "one"
}
}
Run Code Online (Sandbox Code Playgroud)
这是整个代码,如果你需要看看它们如何组合在一起:
class ModelController {
public static function execute($sql, $vals) {
var_dump($vals);
}
}
class ModelContainer {
private $queries = [];
public function add_model(Model $model, $name) {
$this->queries[$name] = $model;
return $this;
}
public function exec_all() {
foreach($this->queries as $q) {
ModelController::execute(...$q->fetch());
}
}
public function exec($name) {
} …Run Code Online (Sandbox Code Playgroud) 我试图允许用户使用带有产品信息的Laravel Excel文件下载 Excel 。我当前的网络路线如下所示:
Route::get('/excel/release', 'ExcelController@create')->name('Create Excel');
Run Code Online (Sandbox Code Playgroud)
我当前的导出如下所示:
class ProductExport implements FromQuery
{
use Exportable;
public function __construct(int $id)
{
$this->id = $id;
}
public function query()
{
return ProductList::query()->where('id', $this->id);
}
}
Run Code Online (Sandbox Code Playgroud)
我当前的控制器如下所示:
public function create(Request $request) {
# Only alowed tables
$alias = [
'product_list' => ProductExport::class
];
# Ensure request has properties
if(!$request->has('alias') || !$request->has('id'))
return Redirect::back()->withErrors(['Please fill in the required fields.'])->withInput();
# Ensure they can use this
if(!in_array($request->alias, array_keys($alias)))
return Redirect::back()->withErrors(['Alias ' . $request->alias …Run Code Online (Sandbox Code Playgroud) 当尝试从 my 获取第一行时transaction,我收到错误:
java.lang.IllegalStateException:上下文中没有事务。
我的代码如下所示:
fun loadPlayer(client: Client): PlayerLoadResult {
var player = transaction {
PlayerModel.select {
PlayerModel.username eq client.loginUsername
}
}.firstOrNull() ?: return PlayerLoadResult.NEW_ACCOUNT
// ...
return PlayerLoadResult.LOAD_ACCOUNT
}
Run Code Online (Sandbox Code Playgroud)
我的PlayerModel看起来像这样:
object PlayerModel : Table("Players") {
val id = integer("id").autoIncrement().primaryKey()
val username = varchar("username", 60).uniqueIndex()
val displayName = varchar("display_name", 60).uniqueIndex()
val x = integer("position_x")
val height = integer("position_y")
val z = integer("position_z")
val privilege = integer("privilege").default(1)
val runEnergy = float("run_energy").default(100.toFloat())
val displayMode = integer("display_mode").default(0)
val hash …Run Code Online (Sandbox Code Playgroud) 我想要一个帖子描述,但只显示第一个,例如,30个字母,但忽略任何标签和空格.
$msg = 'I only need the first, let us just say, 30 characters; for the time being.';
$msg .= ' Now I need to remove the spaces out of the checking.';
$amount = 30;
// if tabs or spaces exist, alter the amount
if(preg_match("/\s/", $msg)) {
$stripped_amount = strlen(str_replace(' ', '', $msg));
$amount = $amount + (strlen($msg) - $stripped_amount);
}
echo substr($msg, 0, $amount);
echo '<br /> <br />';
echo substr(str_replace(' ', '', $msg), 0, 30);
Run Code Online (Sandbox Code Playgroud)
第一个输出给了我'我只需要第一个,我们只说30个字符;' 而第二个输出给了我: …
我一直在研究如何使用Laravel 加密,因为构建宅基地加密平台是不受欢迎的,也是理所当然的。
Illuminate\Support\Facades\Crypt::encryptString('This is a secret message from user 1 to user 2');
Run Code Online (Sandbox Code Playgroud)
以上面的例子为例,这是使用APP_KEY从我的.env文件派生的 my ,以前由php artisan key:generate. 问题是用户 1 永远不会被分配两组密钥来仅与用户 2通信。用户 3、4 等仍然可以使用该Illuminate\Support\Facades\Crypt::decryptString方法读取此消息。
目前,我的数据库设置为具有聊天标题。这包含的信息有什么是通信。所有参与者都将使用这些密钥进行加密和解密——因此任何外部用户都无法解密消息。
public function up()
{
Schema::create('chat_headers', function(Blueprint $table) {
$table->increments('id');
$table->timestamp('created_at')->default(DB::raw('CURRENT_TIMESTAMP'));
$table->timestamp('updated_at')->default(DB::raw('CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP'));
$table->string('private_key')->unique();
$table->string('public_key')->unique();
});
}
Run Code Online (Sandbox Code Playgroud)
我也有一个聊天参与者,其中包含有关谁在通信的信息:
public function up()
{
Schema::create('chat_participants', function(Blueprint $table) {
$table->increments('id');
$table->timestamp('created_at')->default(DB::raw('CURRENT_TIMESTAMP'));
$table->timestamp('updated_at')->default(DB::raw('CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP'));
$table->integer('user_id')->unsigned();
# TODO: Build RBAC
$table->index(['user_id']); …Run Code Online (Sandbox Code Playgroud) 连接的设备:
它正在运行开发者选项并启用了 USB 调试
它使用 MTP 作为设备文件管理器
驱动程序已安装到笔记本电脑上,没有任何问题,我可以正常浏览文件
当我运行:ionic cordova run android --device我得到这个输出:
BUILD SUCCESSFUL in 5s
42 actionable tasks: 42 up-to-date
Built the following apk(s):
C:\Users\K-PC\myApp\platforms\android\app\build\outputs\apk\debug\app-debug.apk
native-run.cmd android --app platforms\android\app\build\outputs\apk\debug\app-debug.apk --device
[native-run] ERR_NO_DEVICE: No hardware devices found. Not attempting emulator because --device was specified.
[native-run]
[native-run] More details for this error may be available online:
[native-run]
[native-run] https://github.com/ionic-team/native-run/wiki/Android-Errors
[ERROR] An error occurred while running subprocess native-run.
native-run.cmd android --app platforms\android\app\build\outputs\apk\debug\app-d... exited with exit code 1.
Re-running this …Run Code Online (Sandbox Code Playgroud) 我正在研究一个使用Entity Framework的小项目,我目前正在学习ASPxGridView,但是,我似乎无法在互联网上找到任何与向列添加规则相关的内容,然后根据列显示图标或突出显示行.规则集.
像这样:https://demos.devexpress.com/ASPxGridViewDemos/Rows/ConditionalFormatting.aspx
如果有人可以发给我任何他们可以找到的参考资料,这可能有助于我指出正确的方向,我们将不胜感激.
谢谢.
我目前有一个依赖注入模块,它允许我创建一个对象工厂:
class DiModule
{
private $Callbacks;
public function set(
$foo,
$bar
) {
$this->Callbacks[$foo] = $bar;
}
public function get(
$foo
) {
return $this->Callbacks[$foo];
}
}
Run Code Online (Sandbox Code Playgroud)
然后我有一个事件对象,它存储方法闭包和将触发事件的会话.
class Event
{
private $Sesh;
private $Method;
public function set(
$sesh = array(),
$method
) {
$this->Sesh = $sesh;
$this->Method = $method;
}
public function get(
) {
return [$this->Sesh,$this->Method];
}
}
Run Code Online (Sandbox Code Playgroud)
然后我有一个侦听器对象,它搜索会话集并触发与该对象关联的事件.
class Listener
{
private $Sesh;
public function setSesh(
$foo
) {
$this->Sesh = $foo;
}
private $Event;
public function …Run Code Online (Sandbox Code Playgroud) 我有一个应用程序的数组列表,我有一个目录,它只包含jar文件(我使用反射来访问我平台中的这些jar文件).我想循环遍历目录中的所有文件,查找所有jar文件,然后检查它们是已验证应用程序的数组列表的一部分,并从中构建一个新的数组列表,其中包含所有已验证的文件和存在.
到目前为止,我有这个:
App.getAppStore()
.stream()
.filter(o -> {
File[] listOfFiles = new File("C:/Temp/MyApps/").listFiles();
Object[] foo = Arrays.stream(listOfFiles)
.filter(x -> x.getName().contains(o.getName()))
.toArray();
return true;
}).toArray();
Run Code Online (Sandbox Code Playgroud)
然而,这给了我arraylist里面的所有内容,即使它们不存在于文件中.任何帮助将不胜感激,我想使用流.
我想转此:
ArrayList<Application> verifiedApps = new ArrayList<verifiedApps>();
for( Application app : App.getAppStore() ) {
for( File verifiedApp : new File("C:/Temp/MyApps/").listFiles() ) {
if( verifiedApp.getName().contains( app.getName() )
verifiedApps.add( app );
}
}
Run Code Online (Sandbox Code Playgroud)
使用流来习惯了解如何使用流.
我在Laravel.io上找到了一篇关于如何将 Laravel 会话加载到 Ratchet 中的帖子,该帖子已过时并使用 Laravel 5.4,因此我更改了一些内容以使其与 Laravel 8.x 一起使用
public function onOpen(ConnectionInterface $conn)
{
// Attach connection
$this->clients->attach($conn);
// Create a new session handler for this client
$session = (new SessionManager(App::getInstance()))->driver();
// Get the cookies
$cookiesRaw = $conn->httpRequest->getHeader('Cookie');
$cookies = [];
if(count($cookiesRaw)) {
$cookies = Header::parse($cookiesRaw)[0]; // Array of cookies
}
// Get the laravel's one - todo: try catch
$sessionId = Crypt::decrypt(urldecode($cookies[Config::get('session.cookie')]), false);
var_dump($sessionId);
// Set the session id to the session handler
$session->setId($sessionId); …Run Code Online (Sandbox Code Playgroud)