PHP code example of weifd / tools

1. Go to this page and download the library: Download weifd/tools 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/ */

    

weifd / tools example snippets


use \Tools\Arr;

Arr::array2Object();

use \Tools\Sql;

$arr = [
    [
        'name' => 'zhang3',
        'age' => '20',
        'height' => 180,
    ],
    [
        'name' => 'li4',
        'age' => '25',
        'height' => 170,
    ],
];
echo Sql::insertSql('user',$arr);
//INSERT INTO `user`( `name` ,`age` ,`height` ) values ('zhang3','20','180') , ('li4','25','170');

echo Sql::updateFiledSql('user',$arr,'name','id');
//UPDATE `user` SET `name` = CASE `id`  WHEN 1 THEN 'zhangsan'  WHEN 2 THEN 'lisi'  WHEN 3 THEN 'wangwu' END WHERE `id` IN (1,2,3);