首页Web开发AndroidJ2EEPHPLinux/Un">
时间:2021-07-01 10:21:17 帮助过:13人阅读
$vip='0004956321';
$field_values_vip = array(
"vip" => $vip
);
autoExecute('table',$field_values_vip);
function autoExecute($table, $field_values, $mode = 'INSERT', $where = '', $querymode = '')
{
#$field_names = $this->getCol('DESC ' . $table);
$field_names = array('vip');
$sql = '';
if ($mode == 'INSERT')
{
$fields = $values = array();
foreach ($field_names AS $value)
{
if (array_key_exists($value, $field_values) == true)
{
$fields[] = $value;
$values[] = "'" . $field_values[$value] . "'";
}
}
if (!empty($fields))
{
$sql = 'INSERT INTO ' . $table . ' (' . implode(', ', $fields) . ') VALUES (' . implode(', ', $values) . ')';
}
}
else
{
$sets = array();
foreach ($field_names AS $value)
{
if (array_key_exists($value, $field_values) == true)
{
$sets[] = $value . " = '" . $field_values[$value] . "'";
}
}
if (!empty($sets))
{
$sql = 'UPDATE ' . $table . ' SET ' . implode(', ', $sets) . ' WHERE ' . $where;
}
}
echo $sql;
/*if ($sql)
{
return $this->query($sql, $querymode);
}
else
{
return false;
}*/
}
?>