<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
>
<channel>
<title><![CDATA[Genius的博客]]></title> 
<atom:link href="https://www.ym6888.cn/rss.php" rel="self" type="application/rss+xml" />
<description><![CDATA[Genius的博客]]></description>
<link>https://www.ym6888.cn/</link>
<language>zh-cn</language>
<generator>www.emlog.net</generator>
<item>
    <title>thinkphp5单一上传和批量上传</title>
    <link>https://www.ym6888.cn/?post=19</link>
    <description><![CDATA[<pre><code class="language-php">&lt;?php
namespace app\before\controller;
use think\facade\Request;
class Upload 
{

    public function Index()
    {
       $file = Request::file('file');

       $info = $file-&gt;move('../public/static/cs');
       if ($info) {
           echo $info-&gt;getExtension();//文件类型
           echo '&lt;br&gt;';
           echo $info-&gt;getSaveName();//文件地址和名字
           echo '&lt;br&gt;';
           echo $info-&gt;getFileName();//文件名
       }else {
           echo $file-&gt;getError();
       }
    }
    public function Uploads()
    {
       $files = Request::file('file');
       foreach ($files as $file){
           $info = $file-&gt;move('../public/static/cs');
           if ($info) {
           echo $info-&gt;getExtension();//文件类型
           echo '&lt;br&gt;';
           echo $info-&gt;getSaveName();//文件地址和名字
           echo '&lt;br&gt;';
           echo $info-&gt;getFileName();//文件名
       }else {
           echo $file-&gt;getError();
       }
       }

    }
}

?&gt;</code></pre>
<h3>前端代码如下：</h3>
<pre><code class="language-php">&lt;body&gt;
&lt;form action="/before/upload/uploads" method="post" enctype="multipart/form-data"&gt;
    &lt;input type="file" name="file[]"&gt;
    &lt;input type="file" name="file[]"&gt;
    &lt;input type="file" name="file[]"&gt;
    &lt;input type="submit" value="上传"&gt;
&lt;/form&gt;
&lt;/body&gt;
</code></pre>]]></description>
    <pubDate>Mon, 30 Dec 2024 13:57:00 +0800</pubDate>
    <dc:creator>Genius</dc:creator>
    <guid>https://www.ym6888.cn/?post=19</guid>
</item>
<item>
    <title>thinkphp5 模型获取器</title>
    <link>https://www.ym6888.cn/?post=18</link>
    <description><![CDATA[<p>控制层</p>
<pre><code class="language-php">&lt;?php
namespace app\before\controller;
use think\Controller;
use think\Db;
use app\before\model\Article as ArticleModel;

class Article extends Controller
{

    public function fanyi(){
       $shuchu =  ArticleModel::get(2); 
       return json($shuchu);
    }
}

?&gt;</code></pre>
<p>模型层</p>
<pre><code class="language-php">&lt;?php
namespace app\before\model;

use think\Model;

class Article extends Model
{
   protected $pk = 'article_id';
   public function getcatIdAttr($status){
       $bianliang = [1=&gt; '是1啊',2=&gt;'是2啊'];
       return $bianliang[$status];
   }
}

?&gt;</code></pre>]]></description>
    <pubDate>Fri, 20 Dec 2024 15:22:00 +0800</pubDate>
    <dc:creator>Genius</dc:creator>
    <guid>https://www.ym6888.cn/?post=18</guid>
</item>
<item>
    <title>thinkphp5 模型新增/批量删除 闭包删除</title>
    <link>https://www.ym6888.cn/?post=17</link>
    <description><![CDATA[<p>控制文件：</p>
<pre><code class="language-php">&lt;?php
namespace app\before\controller;
use think\Controller;
use think\Db;
use app\before\model\Article as ArticleModel;

class Article extends Controller
{

    public function Ces()
    {
      $add = new ArticleModel;
      $tj = $add-&gt;save([
          'cat_id' =&gt; 8,
          'title' =&gt; '44',
          'content' =&gt; '33',
          'author' =&gt; '22',
          'author_email' =&gt; '11',
          'keywords' =&gt; '99',
          'article_type' =&gt; 7,
          'is_open' =&gt; 6,
          'add_time' =&gt; '1533708992',
          'file_url' =&gt; 55,
          'open_type' =&gt; 4,
          'link' =&gt; 3,
          'description' =&gt; '',
          ]);
      echo $add-&gt;article_id;
    }
    public function dele(){
        //ArticleModel::destroy([212,210,211]); //删除
        ArticleModel::destroy(function($query){
            $query-&gt;where('article_id','&gt;',200);
        });

    }

}

?&gt;</code></pre>
<p>模型文件：</p>
<pre><code class="language-php">&lt;?php
namespace app\before\model;

use think\Model;

class Article extends Model
{
   protected $pk = 'article_id';

}

?&gt;</code></pre>]]></description>
    <pubDate>Thu, 19 Dec 2024 17:08:00 +0800</pubDate>
    <dc:creator>Genius</dc:creator>
    <guid>https://www.ym6888.cn/?post=17</guid>
</item>
<item>
    <title>thinkphp5 子查询 闭包查询</title>
    <link>https://www.ym6888.cn/?post=16</link>
    <description><![CDATA[<p>&lt;?php<br />
namespace app\before\controller;<br />
use think\Controller;<br />
use think\Db;<br />
//use app\before\model\Article;</p>
<p>class Before extends Controller<br />
{</p>
<pre><code>public function Index()
{
    $sj = Db::name('article')-&gt;where('article_id','in',function ($query){
        $query-&gt;name('brand')-&gt;field('brand_id')-&gt;where('brand_name','测试1');
    })-&gt;select();
    return json($sj);

}</code></pre>
<p>}</p>
<p>?&gt;</p>]]></description>
    <pubDate>Wed, 18 Dec 2024 20:03:00 +0800</pubDate>
    <dc:creator>Genius</dc:creator>
    <guid>https://www.ym6888.cn/?post=16</guid>
</item>
<item>
    <title>thinkphp5 增删改查</title>
    <link>https://www.ym6888.cn/?post=15</link>
    <description><![CDATA[<p>&lt;?php<br />
namespace app\before\controller;<br />
use think\Controller;<br />
use think\Db;<br />
//use app\before\model\Article;</p>
<pre><code>class Before extends Controller
{

    public function Index()
    {
        $sj = Db::name('brand');
        $ss = $sj-&gt;where('brand_id',179)-&gt;order('brand_id','desc')-&gt;value('brand_name');
        $sq = $sj-&gt;removeOption('where')-&gt;removeOption()-&gt;select(); //清理上一次where查询保存 安全重要  , 第二个removeOption清理order
       // return json($sq);
       return Db::getlastSql();
      //  $sj = Article::select();
      //  return json($sj);
      $data = [
          'brand_name' =&gt; '测试1',
          'brand_logo' =&gt; '测试2',
          'brand_desc' =&gt; '测试3',
          'site_url' =&gt; '1',
          'sort_order' =&gt; 1,
          'is_show' =&gt; 1,
          ];
      //$updatagai = Db::name('brand')-&gt;where('brand_id',179)-&gt;update($data); //改
      //$insertadd = Db::name('brand')-&gt;insert($data); //新增
     //$del = Db::name('brand')-&gt;delete(186); //删除 默认主键
      //return $del;

    }

}

?&gt;</code></pre>]]></description>
    <pubDate>Wed, 18 Dec 2024 13:49:00 +0800</pubDate>
    <dc:creator>Genius</dc:creator>
    <guid>https://www.ym6888.cn/?post=15</guid>
</item>
<item>
    <title>thinkphp5 查询数据库</title>
    <link>https://www.ym6888.cn/?post=14</link>
    <description><![CDATA[<p>控制层文件</p>
<pre><code>&lt;?php
namespace app\before\controller;
use think\Controller;
use think\Db;
use app\before\model\Article;

class Before extends Controller
{

    public function Index()
    {
      /*  $sj = Db::name('article_cat')-&gt;select();
        return json($sj);*/
        $sj = Article::select();
        return json($sj);
    }

}

?&gt;</code></pre>
<p>模型层文件</p>
<pre><code>&lt;?php
namespace app\before\model;

use think\Model;

class Article extends Model
{

}

?&gt;</code></pre>]]></description>
    <pubDate>Tue, 17 Dec 2024 21:31:00 +0800</pubDate>
    <dc:creator>Genius</dc:creator>
    <guid>https://www.ym6888.cn/?post=14</guid>
</item>
<item>
    <title>thinkphp5空方法检查</title>
    <link>https://www.ym6888.cn/?post=13</link>
    <description><![CDATA[<pre><code class="language-php">&lt;?php
namespace app\test\controller;
use think\Controller;

class YangZheWei
{

    public function _empty($name)
    {

        return '此方法不存在：&lt;br&gt;'.$name;
    }
}

?&gt;</code></pre>]]></description>
    <pubDate>Tue, 17 Dec 2024 17:33:00 +0800</pubDate>
    <dc:creator>Genius</dc:creator>
    <guid>https://www.ym6888.cn/?post=13</guid>
</item>
<item>
    <title>thinkphp5判断跳转</title>
    <link>https://www.ym6888.cn/?post=12</link>
    <description><![CDATA[<pre><code class="language-php">&lt;?php
namespace app\test\controller;
use think\Controller;

class YangZheWei extends Controller
{
    protected $flag = false;

    public function index()
    {
        if($this -&gt; flag){
          $this-&gt;success('注册成功!', 'https://www.xkwo.com/');
        }else{
             $this -&gt; error('失败');
        }
        return '333&lt;br&gt;';
    }
}

?&gt;</code></pre>]]></description>
    <pubDate>Tue, 17 Dec 2024 16:19:00 +0800</pubDate>
    <dc:creator>Genius</dc:creator>
    <guid>https://www.ym6888.cn/?post=12</guid>
</item>
<item>
    <title>thinkphp5 初始化灵活方法</title>
    <link>https://www.ym6888.cn/?post=11</link>
    <description><![CDATA[<p>&lt;?php<br />
namespace app\test\controller;<br />
use think\Controller;</p>
<pre><code>class YangZheWei extends Controller
{
    protected $beforeActionList = [
        'than',
        'first' =&gt; ['except' =&gt; 'one'], //one 方法不可用
        'san' =&gt; ['only' =&gt; 'three,two'], //只能three和two
    ];

    protected function first()
    {
        echo '初始111&lt;br&gt;';
    }
    protected function than()
    {
        echo '初始222&lt;br&gt;';
    }
    protected function san()
    {
        echo '初始333&lt;br&gt;';
    }
    public function one()
    {
        return '111&lt;br&gt;';
    }
    public function two()
    {
        return '222&lt;br&gt;';
    }
    public function three()
    {
        return '333&lt;br&gt;';
    }
}

?&gt;</code></pre>]]></description>
    <pubDate>Tue, 17 Dec 2024 15:28:00 +0800</pubDate>
    <dc:creator>Genius</dc:creator>
    <guid>https://www.ym6888.cn/?post=11</guid>
</item>
<item>
    <title>thinkphp5 初始化</title>
    <link>https://www.ym6888.cn/?post=10</link>
    <description><![CDATA[<p>&lt;?php<br />
namespace app\test\controller;<br />
use think\facade\Env;<br />
use think\Controller;</p>
<p>class YangZheWei extends Controller<br />
{<br />
protected function initialize(){<br />
parent::initialize();<br />
echo 'init';<br />
}<br />
public function index()<br />
{<br />
return Env::get('module_path');<br />
}<br />
public function test()<br />
{<br />
return '12';<br />
}<br />
}</p>]]></description>
    <pubDate>Tue, 17 Dec 2024 14:47:00 +0800</pubDate>
    <dc:creator>Genius</dc:creator>
    <guid>https://www.ym6888.cn/?post=10</guid>
</item></channel>
</rss>