40 lines
1.2 KiB
PHP
40 lines
1.2 KiB
PHP
<?php
|
|
namespace web\api;
|
|
class craw {
|
|
public static function json_getmaxid() {
|
|
global $db;
|
|
$post = new \ciy\post();
|
|
$table = $post->get('table');
|
|
$csql = new \ciy\sql($table);
|
|
$csql->order('id desc');
|
|
$csql->column('id');
|
|
$ret['maxid'] = (int)$db->get1($csql);
|
|
return succjson($ret);
|
|
}
|
|
public static function json_filldata() {
|
|
global $db;
|
|
$post = new \ciy\post();
|
|
$lists = $post->get('list');
|
|
$table = $post->get('table');
|
|
if(is_string($lists))
|
|
$lists = json_decode($lists,true);
|
|
$ret['dataid'] = 0;
|
|
foreach($lists as $list){
|
|
$csql = new \ciy\sql($table);
|
|
$csql->where('id', $list['id']);
|
|
$row = $db->getone($csql);
|
|
if (is_array($row)) {
|
|
if ($db->update($csql, $list) === false)
|
|
throw new \Exception('更新失败:' . $db->error);
|
|
} else {
|
|
if ($db->insert($csql, $list) === false)
|
|
throw new \Exception('新增失败:' . $db->error);
|
|
}
|
|
$ret['dataid'] = $list['id'];
|
|
if($table == 'c_*'){
|
|
}
|
|
}
|
|
return succjson($ret);
|
|
}
|
|
}
|