Skip to content

Instantly share code, notes, and snippets.

@chuanfoo
Last active April 5, 2020 06:34
Show Gist options
  • Save chuanfoo/4789b95a91e54b17ab84b102e9dea98a to your computer and use it in GitHub Desktop.
Save chuanfoo/4789b95a91e54b17ab84b102e9dea98a to your computer and use it in GitHub Desktop.
<snippet>
<content><![CDATA[
var dialog = new auiDialog();
dialog.alert({
title:"弹出提示",
msg:'这里是内容',
buttons:['取消','确定']
},function(ret){
if(ret){
dialog.alert({
title:"提示",
msg:"您点击了第"+ret.buttonIndex+"个按钮",
buttons:['确定']
});
}
});
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>auialert</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>
<snippet>
<content><![CDATA[
var dialog = new auiDialog();
dialog.alert({
title:"弹出提示",
msg:'这里是内容',
buttons:['取消','确定']
},function(ret){
if(ret){
dialog.alert({
title:"提示",
msg:"您点击了第"+ret.buttonIndex+"个按钮",
buttons:['确定']
});
}
});
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>auidialog</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>
<snippet>
<content><![CDATA[
var dialog = new auiDialog();
dialog.prompt({
title:"弹出提示",
text:'默认内容',
type:'number',
buttons:['取消','确定']
},function(ret){
if(ret.buttonIndex == 2){
dialog.alert({
title:"提示",
msg: "您输入的内容是:"+ret.text,
buttons:['确定']
});
}
});
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>auiprompt</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>
<snippet>
<content><![CDATA[
\$this->db->where('id', \$id);
\$this->db->delete('member');
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>cideleterow</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>
<snippet>
<content><![CDATA[
echo json_encode(['e' => 0, 'msg' => '$0']);
exit();
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>ej</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>
<snippet>
<content><![CDATA[
echo json_encode(['e' => 1, 'msg' => '$0']);
exit();
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>eje</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>
<snippet>
<content><![CDATA[
\$data = array(
);
\$this->db->insert('member', \$data);
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>ciinsertrow</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>
<snippet>
<content><![CDATA[
\$insert_id = \$this->db->insert_id();
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>ciinsertid</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>
<snippet>
<content><![CDATA[
echo \$this->db->last_query() . PHP_EOL;
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>cilastquery</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>
<snippet>
<content><![CDATA[
private function _$0()
{
}
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>prf</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>
<snippet>
<content><![CDATA[
public function $0()
{
}
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>pf</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>
<snippet>
<content><![CDATA[
\$sql = "select * from member";
\$query = \$this->db->query(\$sql);
foreach (\$query->result() as \$row)
{
}
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>ciquery</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>
<snippet>
<content><![CDATA[
\$sql = "select * from member where id=\$id";
\$row = \$this->db->query(\$sql)->row();
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>cirow</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>
<snippet>
<content><![CDATA[
// 事务处理 start
\$this->db->trans_begin();
// 执行操作 start
// 执行操作 end
if (\$this->db->trans_status() === FALSE)
{
\$this->db->trans_rollback();
echo json_encode(array('e' => 1, 'msg' => '操作失败'));
exit();
}
else
{
\$this->db->trans_commit();
echo json_encode(array('e' => 0, 'msg' => '操作成功'));
exit();
}
// 事务处理 end
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>citransaction</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>
<snippet>
<content><![CDATA[
\$this->db->set('ispay', 1);
\$this->db->where('id', \$id);
\$this->db->update('member');
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>ciupdate0</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>
<snippet>
<content><![CDATA[
// gives UPDATE mytable SET field = field+1 WHERE id = 2
\$this->db->set('field', 'field+1', FALSE);
\$this->db->where('id', \$id);
\$this->db->update('member');
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>ciupdate1</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>
<snippet>
<content><![CDATA[
\$names = array('Frank', 'Todd', 'James');
\$this->db->where_in('username', $names);
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>ciwherein</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>
<snippet>
<content><![CDATA[
console.log(JSON.stringify(ret));
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>clog</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>
{
"extensions":
[
"wxss"
]
}
{
"command": "D:/software/ctags58/ctags.exe"
}
<snippet>
<content><![CDATA[
function curl_post(\$url,\$data,\$header = '',\$post=1)
{
//初始化curl
\$ch = curl_init();
//参数设置
\$res= curl_setopt (\$ch, CURLOPT_URL,\$url);
curl_setopt(\$ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt(\$ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt (\$ch, CURLOPT_HEADER, 0);
curl_setopt(\$ch, CURLOPT_POST, \$post);
if(\$post) {
curl_setopt(\$ch, CURLOPT_POSTFIELDS, \$data);
}
curl_setopt (\$ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt(\$ch,CURLOPT_HTTPHEADER,\$header);
\$result = curl_exec (\$ch);
//连接失败
if(\$result == FALSE){
return false;
}
curl_close(\$ch);
return \$result;
}
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>curl</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>
[
{ "keys": ["ctrl+alt+b"], "command": "alignment" }
]
<snippet>
<content><![CDATA[
\$sql = "UPDATE `#@__$0` SET `delstate`='' WHERE id='\$id'";
\$dosql->ExecNoneQuery(\$sql);
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>doe</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>
<snippet>
<content><![CDATA[
\$sql = "select * from `#@__member`";
\$row = \$dosql->GetOne(\$sql);
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>doone</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>
<snippet>
<content><![CDATA[
\$sql = "select * from `#@__member`";
\$dosql->Execute(\$sql);
while(\$row = \$dosql->GetArray()) {
${0}
}
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>dowhile</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>
<snippet>
<content><![CDATA[
\$data = array();
echo json_encode(array('status' => 200, 'msg' => 'ok', 'data' => \$data));
exit();
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>ejd</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>
<snippet>
<content><![CDATA[
// log start
\$file = fopen('log.txt', 'a+');
\$str = '' . PHP_EOL;
fwrite(\$file, \$str);
fclose(\$file);
// log end
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>xf</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>
<snippet>
<content><![CDATA[
\$id = intval(\$_GET['id']);
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>get</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>
<snippet>
<content><![CDATA[
\$id = intval(\$_POST['id']);
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>post</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>
{
"extensions":
[
"wxml"
]
}
<snippet>
<content><![CDATA[
if (strpos(\$_SERVER['HTTP_USER_AGENT'], 'MicroMessenger') !== false) {
}
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>iswechat</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>
<snippet>
<content><![CDATA[
<% if(true) { %>
<% } else { %>
<% } %>
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>jsifelse</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>
<snippet>
<content><![CDATA[
<% if(true) { %>
<% } %>
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>jsif</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>
<snippet>
<content><![CDATA[
layer.open({
content:'',
skin:'msg',
time:2,
end:function(){
}
});
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>layertoast</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>
<snippet>
<content><![CDATA[
\$condition = [
'name' => 'jalyse_setting',
];
\$row = Model()->table('setting')->where(\$condition)->find();
\$config = unserialize(\$row['value']);
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>ncconfig</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>
<snippet>
<content><![CDATA[
\$config = F('setting');
\$var = \$config['var'];
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>ncconfig2</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>
<snippet>
<content><![CDATA[
\$table = '';
\$condition = [];
\$c = Model()->table(\$table)->where(\$condition)->count();
\$c = intval(\$c);
if (\$c > 0) {
}
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>nccount</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>
<snippet>
<content><![CDATA[
\$table = '';
\$condition = [
'' => '',
];
\$delete = Model()->table(\$table)->where(\$condition)->delete();
if (!\$delete) {
throw new Exception("操作失败", 1);
// showMessage('操作失败');
// output_error('操作失败');
}
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>ncdelete</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>
<snippet>
<content><![CDATA[
\$table = '$1';
\$condition = [
'member_acc' => ['gt', 0],
];
\$row = Model()->table(\$table)->where(\$condition)->find();
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>ncfind</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>
<snippet>
<content><![CDATA[
\$table = '';
\$data = [
'' => '',
];
\$insert = Model()->table(\$table)->insert(\$data);
if (!\$insert) {
throw new Exception("操作失败", 1);
// showMessage('操作失败');
// output_error('操作失败');
}
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>ncinsert</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>
<snippet>
<content><![CDATA[
\$data = [];
output_data(\$data);
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>ncod</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>
<snippet>
<content><![CDATA[
output_error('error');
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>ncoe</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>
<snippet>
<content><![CDATA[
require_once(BASE_RESOURCE_PATH.DS.'phpqrcode'.DS.'index.php');
// str数据
\$str = '';
\$png_name = '.png';
\$PhpQRCode = new PhpQRCode();
\$PhpQRCode->set('pngTempDir',BASE_UPLOAD_PATH.DS.ATTACH_STORE.DS);
\$PhpQRCode->set('date', \$str);
\$PhpQRCode->set('pngTempName', \$png_name);
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>ncqrcode</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>
<snippet>
<content><![CDATA[
\$table = '';
\$condition = [
'member_time' => ['gt', 0],
];
\$list = Model()->table(\$table)->where(\$condition)->select();
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>ncselect</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>
<snippet>
<content><![CDATA[
showMessage('参数错误');
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>ncshow</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>
<snippet>
<content><![CDATA[
\$model = new Model();
\$sum = \$model->table('')->sum('');
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>ncsum</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>
<snippet>
<content><![CDATA[
\$result = \$model->table(\$table)->clear();
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>ncclear</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>
<snippet>
<content><![CDATA[
\$model = Model();
try {
\$model->beginTransaction();
\$condition = [
'id' => \$id,
];
\$data = [
'key' => 'value',
'amount' => ['exp', 'amount + ' . \$amount_plus],
];
\$update = Model()->table("table")->where(\$condition)->update(\$data);
if (!\$update) {
throw new Exception('操作失败');
}
\$model->commit();
output_data("success");
} catch (Exception \$e) {
\$model->rollback();
output_error(\$e->getMessage());
}
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>nctransaction</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>
<snippet>
<content><![CDATA[
\$table = '${0}';
\$condition = [
'id' => \$id,
];
\$data = [
'key' => 'value',
'amount' => ['exp', 'amount + 100'],
];
\$update = Model()->table(\$table)->where(\$condition)->update(\$data);
if (!\$update) {
throw new Exception("操作失败", 1);
// showMessage('操作失败');
// output_error('操作失败');
}
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>ncupdate</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>
{
"bootstrapped": true,
"channels":
[
"C:\\Users\\chuan\\AppData\\Local\\Sublime Text 3\\channel_v3.json"
],
"in_process_packages":
[
],
"installed_packages":
[
"10% Too Dull for My Tastes Color Scheme",
"A File Icon",
"Alignment",
"APICloudSnippets",
"CodeIgniter Snippets",
"CTags",
"DocBlockr",
"Emmet",
"Git",
"HTML5",
"jQuery",
"Material Theme",
"Oceanic Color Scheme",
"Package Control",
"PhpDoc",
"Sublime wxapp",
"SublimeCodeIntel",
"SublimeLinter",
"SublimeLinter-php",
"SublimeLinter-phplint",
"Sync Settings",
"Vue Syntax Highlight",
"WakaTime"
]
}
<snippet>
<content><![CDATA[
\$pattern = "/([a-z0-9]*[-_.]?[a-z0-9]+)*@([a-z0-9]*[-_]?[a-z0-9]+)+[.][a-z]{2,3}([.][a-z]{2})?/i";
\$result = preg_match(\$pattern, \$email);
if (\$result == 0) {
echo '邮箱格式错误';
exit();
}
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>pemail</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>
<snippet>
<content><![CDATA[
\$pattern = "#^[a-zA-Z]{1}[a-zA-Z0-9]{5,15}\$#";
\$result = preg_match(\$pattern, \$userid);
if (\$result == 0) {
echo '用户名必须以字母开头,由6-16位字母或数字组成';
exit();
} else {
\$sql = "select * from member where userid='\$userid'";
\$row = \$this->db->query(\$sql)->row();
if (\$row) {
echo '用户名已被注册,请换一个';
exit();
}
}
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>pname</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>
// These settings override both User and Default settings for the PHP syntax
{
"tab_size": 4,
"translate_tabs_to_spaces": true,
"expand_tabs_on_save": true,
// "highlight_line": true,
// "trim_trailing_white_space_on_save": true,
"rulers": [80]
}
{
"color_scheme": "Packages/Material Theme/schemes/Material-Theme-Palenight.tmTheme",
"default_line_ending": "unix",
"font_size": 11,
"ignored_packages":
[
"Vintage"
],
"theme": "Material-Theme-Palenight.sublime-theme"
}
<snippet>
<content><![CDATA[
public static function $0()
{
}
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>psf</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>
<snippet>
<content><![CDATA[
import pymysql.cursors
# Connect to the database
connection = pymysql.connect(host='localhost',
user='user',
password='passwd',
db='db',
charset='utf8mb4',
cursorclass=pymysql.cursors.DictCursor)
try:
with connection.cursor() as cursor:
# Create a new record
sql = "INSERT INTO `users` (`email`, `password`) VALUES (%s, %s)"
cursor.execute(sql, ('webmaster@python.org', 'very-secret'))
# connection is not autocommit by default. So you must commit to save
# your changes.
connection.commit()
with connection.cursor() as cursor:
# Read a single record
sql = "SELECT `id`, `password` FROM `users` WHERE `email`=%s"
cursor.execute(sql, ('webmaster@python.org',))
result = cursor.fetchone()
print(result)
finally:
connection.close()
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>pymysql</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>
<snippet>
<content><![CDATA[
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>pheader</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>
<snippet>
<content><![CDATA[
return false;
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>rf</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>
<snippet>
<content><![CDATA[
return true;
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>rtr</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>
<snippet>
<content><![CDATA[
return;
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>rt</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>
<snippet>
<content><![CDATA[
<?php foreach(\$data as \$key => \$value):?>
<?php endforeach;?>
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>sforeach</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>
<snippet>
<content><![CDATA[
<?php if():?>
<?php else:?>
<?php endif;?>
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>sif</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>
// SublimeLinter Settings - User
{
"paths": {
"linux": [],
"osx": [],
"windows": [
"D:\\wamp64\\bin\\php\\php7.3.1",
"D:\\wamp64\\bin\\php\\php7.2.14",
"D:\\wamp64\\bin\\php\\php7.1.26",
"D:\\wamp64\\bin\\php\\php7.0.33",
"D:\\wamp64\\bin\\php\\php5.6.40",
]
},
"lint_mode": "save",
}
<snippet>
<content><![CDATA[
if (!\$this->request->isAjax()) {
return \$this->fetch('category_add');
}
// save
if (ArticleCategoryModel::get(['name' => \$this->postData('category')['name']])) {
\$msg = '分类名称已经使用,请换一个';
return \$this->renderError(\$msg);
}
\$category = new ArticleCategoryModel(\$this->postData('category'));
// 过滤post数组中的非数据表字段数据
if (\$category->allowField(true)->save()) {
\$msg = '添加成功';
return \$this->renderSuccess(\$msg, url('content.article/category'));
}
\$msg = '添加失败';
return \$this->renderError(\$msg);
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>tpadd</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>
<snippet>
<content><![CDATA[
<?= \$model['state'] == 1?'checked':'' ?>
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>tpchecked</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>
<snippet>
<content><![CDATA[
\$model = new Model;
\$condition = [
'pids' => ['like', "%,\$pids,%"],
];
\$c = \$model->where(\$condition)->count();
\$c = intval(\$c);
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>tpcount</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>
<snippet>
<content><![CDATA[
Db::name('user')->where('id',1)->find();
Db::name('user')->where('status',1)->select();
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>tpdbrow</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>
<snippet>
<content><![CDATA[
\$model = UserGradeModel::get(\$grade_id);
if (!\$model) {
\$msg = '参数错误';
return \$this->renderError(\$msg);
}
if (\$model->delete()) {
\$msg = '删除成功';
return \$this->renderSuccess(\$msg, url('user.grade/index'));
}
\$msg = '删除失败';
return \$this->renderError(\$msg);
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>tpdelete</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>
<snippet>
<content><![CDATA[
if (!\$this->request->isAjax()) {
\$data = ArticleCategoryModel::get(\$category_id);
if (!\$data) {
\$msg = '信息不存在';
return \$this->renderError(\$msg);
}
return \$this->fetch('category_edit', compact('data'));
}
// save
if (ArticleCategoryModel::get(['name' => \$this->postData('category')['name'] , 'category_id' => ['neq', \$this->postData('category')['category_id']]])) {
\$msg = '分类名称已经使用,请换一个';
return \$this->renderError(\$msg);
}
\$model = new ArticleCategoryModel;
// 过滤post数组中的非数据表字段数据
if (\$model->allowField(true)->isUpdate()->save(\$this->postData('category'))) {
\$msg = '修改成功';
return \$this->renderSuccess(\$msg, url('content.article/category'));
}
\$msg = '修改失败';
return \$this->renderError(\$msg);
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>tpedit</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>
<snippet>
<content><![CDATA[
\$model = new Model;
\$condition = [
'id' => \$id,
];
\$row = \$model->where(\$condition)->find();
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>tpfind</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>
<snippet>
<content><![CDATA[
if (!\$this->request->has('id')) {
\$msg = '参数错误:缺少';
return ['code' => 1, 'msg' => \$msg];
}
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>has</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>
<snippet>
<content><![CDATA[
\$data = [
'' => '',
];
Db::name('user')->insert(\$data);
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>tpinsert</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>
<snippet>
<content><![CDATA[
echo \$this->getLastSql();
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>tplastsql</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>
<snippet>
<content><![CDATA[
<?= \$model['goods_name'] ?>
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>tpvalue</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>
<snippet>
<content><![CDATA[
\$id = intval(\$this->request->post('id'));
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>post</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>
<snippet>
<content><![CDATA[
\$msg = '';
return \$this->renderError(\$msg);
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>tperror</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>
<snippet>
<content><![CDATA[
\$msg = '缺少参数';
return ['code' => 1, 'msg' => \$msg];
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>tperror</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>
<snippet>
<content><![CDATA[
\$msg = '';
return \$this->renderSuccess(\$msg);
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>tpsuccess</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>
<snippet>
<content><![CDATA[
\$msg = 'SUCCESS';
\$data = [
'list' => $list,
];
return ['code' => 0, 'msg' => \$msg, 'data' => \$data];
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>tpsuccess</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>
<snippet>
<content><![CDATA[
\$user = new User(\$this->postData('user'));
// 过滤post数组中的非数据表字段数据
\$user->allowField(true)->save();
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>tpsave</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>
<snippet>
<content><![CDATA[
\$model = new Model;
\$condition = [
'' => '',
];
\$list = \$model->where(\$condition)->select();
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>tpselect</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>
<snippet>
<content><![CDATA[
// 启动事务
Db::startTrans();
try {
\$user_id = 0;
\$c = 1;
\$data = [
'cash' => Db::raw('cash-' . \$c),
];
\$condition = [
'user_id' => \$user_id,
];
if (!Db::name('user')->where(\$condition)->update(\$data)) {
throw new Exception("error", 1);
}
// 提交事务
Db::commit();
} catch (\Exception \$e) {
// 回滚事务
Db::rollback();
}
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>tptrans</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>
<snippet>
<content><![CDATA[
\$model_user = new UserModel;
\$condition = [
'user_id' => \$user_id,
];
\$data = [
'm' => 0,
'cash' => Db::raw('cash-100'),
];
\$update = \$model_user->where(\$condition)->update(\$data);
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>tpupdate</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>
{
"api_key": "06afbe37-0e54-4330-809f-3c346a910812"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment