PHP code example of hillstill / sooh

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

    

hillstill / sooh example snippets


//获取记录总数
$recordCount = $db->getRecordCount('tb_user');
//tb_login_log中取出20121230登入的用户,然后到tb_user表查出uid和phone的对应数组
//phone = array(123123123=>12314123,.....)
$phone = $db->getPair('tb_user','uid','phone',array('uid'=>$db->getCol('tb_login_log','uid',array('ymdLogin'=>'20121230'))));


try{
	//尝试添加,捕获丢出的异常,如果是键重复,改为update, 如果不是键重复,打印日志
	\Sooh\DB\Broker::errorMarkSkip(\Sooh\DB\Error::duplicateKey);
	$db->addRecord('tb_user',array('uid'=>'123123123','phone'=>'12314123'));
}catch(\ErrorException){
	if(\Sooh\DB\Broker::errorIs(\Sooh\DB\Error::duplicateKey)){
		$db->updRecords('tb_user',array('phone'=>'12314123'),array('uid'=>'123123123'));
	}else{
		error_log(Sooh\DB\Broker::lastCmd());
		\\打印日志:[db_host_portIfSetted]insert into tb_user set uid='123123123','phone'=>'12314123'
	}
}