1. Go to this page and download the library: Download starrysea/database library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
starrysea / database example snippets
use Starrysea\Database\Expansion;
class User
{
use Expansion;
// 通知扩展这是账户模型
protected $account_model = true;
}
use App\Models\User;
class ExpansionGatherTest
{
public static function unixtime()
{
return User::unixtime('intimes')->find(1); // intimes => 2018-11-26 12:25:59
// return User::unixtime('intimes', '%Y-%m-%d')->find(1); // intimes => 2018-11-26
}
public static function isWhere()
{
$dataone = '蔡星月';
$datatwo = '';
return User::where('id', 1)->isWhere('name', $dataone)->get(); // []
// return User::where('id', 1)->isWhere('name', '<>', $dataone)->get(); // [User]
// return User::where('id', 1)->isWhere('name', $datatwo)->get(); // [User]
}
public static function isorWhere()
{
$dataone = '蔡星月';
$datatwo = '';
return User::where('id', 1)->isorWhere('name', $dataone)->get(); // [User]
// return User::where('id', 1)->isorWhere('name', $datatwo)->get(); // [User]
}
public static function isWhereBranchsieve()
{
$data = '蔡星月';
return User::isWhereBranchsieve(
$data, // content
'id', // accurate filed
['name'] // participle filed
)->toSql(); // select * from `xh_users` where (`id` = ? or ((`name` like ?) and (`name` like ?)))
}
public static function worddivision()
{
$data = '蔡星月';
return User::worddivision($data, function ($query, $words, $data){ // success
// $words => ['蔡', '星月']
// $data => '蔡星月'
}, function ($query, $words, $data){ // error
// $words => false
// $data => source
})->find(1);
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.