小编Szy*_*zyk的帖子

使用PHP <和>运算符返回null

有人可以解释在这些语句中如何映射null吗?

null>0; //=> bool(false)
null<0; //=> bool(false)
null==0; //=> bool(true)
Run Code Online (Sandbox Code Playgroud)

null<-1; // => bool(true)
Run Code Online (Sandbox Code Playgroud)

我认为这是一些映射问题,但不能破解它.

尝试使用带有Suhosin-Patch的PHP 5.3.5-1.

php mapping comparison null operators

24
推荐指数
1
解决办法
3951
查看次数

如何从原始sql文件中清除注释

我有清除注释和已存在的SQL文件中的空行的问题.该文件有超过10k行,因此不能手动清理它.

我有一个小python脚本,但我不知道如何处理多行插入内的注释.

码:

f = file( 'file.sql', 'r' )
t = filter( lambda x: not x.startswith('--') \
            and not x.isspace() 
  , f.readlines() )
f.close()
t #<- here the cleaned data should be
Run Code Online (Sandbox Code Playgroud)

它应该如何工作:

这应该清理:

-- normal sql comment
Run Code Online (Sandbox Code Playgroud)

这应保持原样:

CREATE FUNCTION func1(a integer) RETURNS void
    LANGUAGE plpgsql
    AS $$
BEGIN
        -- comment
       [...]
END;
$$;

INSERT INTO public.texts (multilinetext) VALUES ('
and more lines here \'
-- part of text 
\'
[...]

');
Run Code Online (Sandbox Code Playgroud)

python sql postgresql text-parsing

10
推荐指数
2
解决办法
4014
查看次数

标签 统计

comparison ×1

mapping ×1

null ×1

operators ×1

php ×1

postgresql ×1

python ×1

sql ×1

text-parsing ×1