先说再写:
composer global require hirak/prestissimo
膘叔的简单人生
先说再写:
composer global require hirak/prestissimo
mysql在升到php7后,原有的mysql_*函数都没有了,如果要迁移,可以参考 这一篇:https://stackoverflow.com/questions/36073703/mysql-to-pdo-comparison-table
|
|
MySQL_ Original Driver to PDO Comparative TableIntroduction: This table is not intended to be a tutorial or a guide to PDO, but to provide a correspondence between MySQL_ and PDO. So, some important PDO commands are missing, if they don't have a MySQL_ correspondence. Among these omitted commands, there is a major PDO feature, the prepared statements. I strongly recommend to use it, also if only cited in this guide. This is a very extended answer. I'm sorry for the low quality of spelling (I'm not english) and for the typos. I will try to correct and improve it in the next few days. Any suggestion or contribution is welcome. Naming Conventions: To avoid misunderstanding, in this answer I use:
In PDO, we have two major object types, the PDOObject (the connection between PHP and a database server) and the PDOStatement (a prepared statement and, after the statement is executed, an associated result set). In this answer, variable names are:
|
当然 ,之前yii2有一个queue,这个queu简单到只有一个run/job,其他都没有。这回终于来一个完善的了。说实话,有时候用laravel,就是因为想用他的queue。现在终于不用纠结了!
再细看一下他的composer.json。。。还是逃不脱SF的大坑!不过总算是有队列了,管它呢。这年头,所有框架最后都会被SF大一统么?
先到这里看一下教程:https://github.com/yiisoft/yii2-queue/blob/master/docs/guide/README.md
然后再回到:https://github.com/yiisoft/yii2-queue ,下载代码吧,真正使用也简单,php composer.phar require --prefer-dist yiisoft/yii2-queue,就完事了!
不过这个玩意,估计在windows下面是无效的,常用方法有:
// Push a job into queue and get massage ID.
$id = Yii::$app->queue->push(new SomeJob());
// The job is waiting for execute.
Yii::$app->queue->isWaiting($id);
// Worker gets the job from queue, and executing it.
Yii::$app->queue->isReserved($id);
// Worker has executed the job.
Yii::$app->queue->isDone($id);
估计以后的项目,默认就直接引用:yiisoft/yii2 , yiisoft/yii2-queue了!
看这里: https://blog.jetbrains.com/phpstorm/2017/06/php-annotated-monthly-june-2017/
PHP 7.2 will have some great new features, keep your eye on this blog for a roundup once I’ve had a chance to look at the alpha in the coming weeks.
Other good posts on PHP and general development this month:
We’ve got the usual slew of Laravel and Zend Framework posts, along with some interesting posts for WordPress, Yii and some more useful articles on Composer and Packagist.
Yii
Laravel
Zend Framework
Symfony
Other
There was an interesting interview with Taylor Otwell, creator and lead developer of Laravel tells us why Taylor Otwell Wants You To Build Your PHP Apps On Laravel. I also enjoyed an interview with Anna Filina On PHP Trainings And Future Of PHP Frameworks.
An interesting question is posed in Can 9-to-5 Developers Be Good Developers? While I disagree vehemently with some of the points made in the article, it makes for an interesting discussion.
This month I’ll be at PHP South Coast in Portsmouth this week, and DPC in Amsterdam at the end of the month. Make sure you come and say “Hi!” if you see me at any events.
如果仅仅是多个orwhere条件,其实就是默认的andWhere和orWhere的标准写法,但如果条件是:
$files = XXXX::find()
->andWhere(['<>', 'queue_name', ''])
->andWhere(['or',
['queue_status' => ''],
[
'and',
['queue_status' =>'error'],
['retry' => 0]
]
])
->all();
TCPDF支持一些字体来直接显示中文而不需要外挂字体。这些字体名字为:stsongstdlight,kozminproregular,cid0cs,cid0ct,别纠结它为什么这么怪
<?php
$fontname = TCPDF_FONTS::addTTFfont(public_path('fonts/simhei.ttf'), 'TrueTypeUnicode', '', 64);
$pdf->SetFont($fontname, '', 20);
标题对应的代码会报错:Use of undefined constant php - assumed 'php'
<?php//test
原本以为是很简单的一个用法。
Lumen在初次安装好启动的时候,访问会出现:NotFoundHttpException
找了一下原因,在stackoverflow上有很多人提出来。常见的有这两种:在public/index.php里修改最后的$app->run();
一个很简单的laravel代码:
User::where('id',1)->update(['last_login'=>time()]);
/**
* Update a record in the database.
*
* @param array $values
* @return int
*/
public function update(array $values)
{
return $this->toBase()->update($this->addUpdatedAtColumn($values));
}
When issuing a mass update via Eloquent, the saved and updated model events will not be fired for the updated models. This is because the models are never actually retrieved when issuing a mass update.
You need to retrieve the user from the database and then save that user in order to fire the event. For example:
This will NOT fire the update event:
User::where('id', $id)->update(['username' => $newUsername]);
This will fire the update event:
User::find($id)->update(['username' => $newUsername]);
/**
* Log a query in the connection's query log.
*
* @param string $query
* @param array $bindings
* @param float|null $time
* @return void
*/
public function logQuery($query, $bindings, $time = null)
{
if (isset($this->events)) {
$this->events->fire(new Events\QueryExecuted(
$query, $bindings, $time, $this
));
}
if ($this->loggingQueries) {
$this->queryLog[] = compact('query', 'bindings', 'time');
}
}
/**
* Register a database query listener with the connection.
*
* @param \Closure $callback
* @return void
*/
public function listen(Closure $callback)
{
if (isset($this->events)) {
$this->events->listen(Events\QueryExecuted::class, $callback);
}
}
/**
* Fire an event for this connection.
*
* @param string $event
* @return void
*/
protected function fireConnectionEvent($event)
{
if (! isset($this->events)) {
return;
}
switch ($event) {
case 'beganTransaction':
return $this->events->fire(new Events\TransactionBeginning($this));
case 'committed':
return $this->events->fire(new Events\TransactionCommitted($this));
case 'rollingBack':
return $this->events->fire(new Events\TransactionRolledBack($this));
}
}