quoting

My Zend Framework 'quoting' mess

蓝咒 提交于 2019-12-05 16:50:47
I've got a probably very simple issue to which I can't find a satisfactory (subjectively seen) answer in the Zend Framework manual or elsewhere... There are so many ways how I can hand over my php variables to my sql queries that I lost the overview and probably I lack some understanding about quoting in general. Prepared Statements $sql = "SELECT this, that FROM table WHERE id = ? AND restriction = ?"; $stmt = $this->_db->query($sql, array($myId, $myValue)); $result = $stmt->fetchAll(); I understand that with this solution I don't need to quote anything because the db handles this for me.

How can I do ANSI C quoting of an existing bash variable?

喜欢而已 提交于 2019-12-05 13:31:12
I have looked at this question , but it does not cover my use case. Suppose I have the variable foo which holds the four-character literal \x60 . I want to perform ANSI C Quoting on the contents of this variable and store it into another variable bar . I tried the following, but none of them achieved the desired effect. bar=$'$foo' echo $bar bar=$"$foo" echo $bar Output: $foo \x61 Desired output (actual value of \x61 ): a How might I achieve this in the general case, including non-printable characters? Note that in this case a was used just as an example to make it easier to test whether the

See exact content of bash variable? (hexdump doesn't help)

假装没事ソ 提交于 2019-12-05 12:56:04
So I have a problem below, but my question is more generic - how to see exact content of memory referenced by bash variable to understand why they don't match: # [[ $c1 == $c ]] || echo nope nope # [[ $c1 == "bkup dt" ]] || echo nope # [[ $c == "bkup dt" ]] || echo nope nope # hexdump -C <<<$c 00000000 62 6b 75 70 20 64 74 0a |bkup dt.| 00000008 # hexdump -C <<<$c1 00000000 62 6b 75 70 20 64 74 0a |bkup dt.| 00000008 # [ "$c1" = "$c" ] || echo nope nope # [ ! "$c1" = "$c" ] || echo nope Or does it look like a bug? I can repeat the problem with: $ cd /tmp $ mkdir aaa $ echo 2 > aaa/1 $ echo 2 >

How do I escape single quote in command line query of psql?

拥有回忆 提交于 2019-12-05 05:56:58
I googled a lot but.. How do I escape single quote in command line query of psql ? psql -t -A -F $'\t' postgresql://zzzz:5432/casedb -U qqqq -c 'select id,ext_ids ->> 'qwe' as qwe from data ORDER BY qwe' > /jdata/qwe.tab Results in error ERROR: column "qwe" does not exist LINE 1: select id,ext_ids ->> qwe as qwe from data... In Postgres you can use dollar-quoted strings : select id,ext_ids ->> $$qwe$$ as qwe from data ORDER BY qwe; -- or select id,ext_ids ->> $anything$qwe$anything$ as qwe from data ORDER BY qwe; You could just use double quotes ( " ) for the shell quoting and single quotes (

Using Make $(dir) or $(notdir) on a path with spaces

老子叫甜甜 提交于 2019-12-05 00:39:27
问题 I'm using code similar to the following in a Makefile: empty:= space:= $(empty) $(empty) path_escape = $(subst $(space),\$(space),$(1)) TOP=$(call path_escape,$(abspath .)) TARGET=$(TOP)/foo $(info TOP='$(TOP)') $(info TARGET='$(TARGET)') all: $(TARGET) $(TARGET): touch '$(notdir $@)' .PHONY: $(TARGET) If I use this in a directory with no spaces, say space-test , it works fine: $ make TOP='/tmp/space-test' TARGET='/tmp/space-test/foo' touch 'foo' However, if I use it in a directory with

Can't pass a script block as a parameter to powershell.exe via -Command

不羁岁月 提交于 2019-12-04 19:39:54
I'm trying this $Global:commandBlock={ Start-Transcript -path $projectFolder\gruntLog.txt; grunt $argList; Stop-Transcript } $cmdProc=start-process powershell -ArgumentList ('-command `$Global:commandBlock') -WorkingDirectory $fwd -PassThru -NoNewWindow:$NoNewWindow And keep getting $commandBlock : The term '$Global:commandBlock' is not recognized as the name of a cmdlet, function, script file, or operable program. My guess was it has to do with scope. But making variable global didn't help. Adding -args $commandBlock like that: -ArgumentList ('-command `$Global:commandBlock -args "

Perl one-liner with single quote

限于喜欢 提交于 2019-12-04 13:17:12
问题 I was use a Perl one-liner to create an SQL statement, but I am not able to include single quotes. This is what I want: Take first filed and add quotes to it. echo "a,b" | perl -F',' -lane 'print $F[0];' 'a' I tried a few different ways, but it didn't work for me. 1. echo "a,b" | perl -F',' -lane 'print qq('$F[0]');' [0] 2. echo "a,b" | perl -F',' -lane 'print q('$F[0]');' [0] Here is another interesting. It is printing a single quote with the print statement, but if I assign a value to the

Parsing of HTTP Headers Values: Quoting, RFC 5987, MIME, etc

孤者浪人 提交于 2019-12-04 06:41:07
What confuses me is decoding of HTTP header values . Example Header: Some-Header: "quoted string?"; *utf-8'en'Weirdness Can header value's be quoted? What about the encoding of a " itself? is ' a valid quote character? What's the significance of a semi-colon ( ; )? Could the value parser for a HTTP header be considered a MIME parser? I am making a transparent proxy that needs to transparently handle and modify many in-the-wild header fields. That's why I need so much detail on the format. Can header values be quoted? If you mean does the RFC 5987 parameter production apply to the main part of

Raising error in postgreSQL

巧了我就是萌 提交于 2019-12-04 05:29:33
CREATE OR REPLACE FUNCTION msgfailerror() RETURNS trigger AS ' BEGIN IF NEW.noces< new.first_column THEN RAISE EXCEPTION 'cannot have a negative salary'; END IF; return new; END' LANGUAGE plpgsql Trigger create trigger msgfail before insert on first for each row execute procedure msgfailerror() Giving error: syntax error at or near "cannot" LINE 5: RAISE EXCEPTION 'cannot have a negative ... I have almost one validation for each field of row. I want trigger to check all validations while insertion is being done and, raise error log afterwards once for all. Should I use raise exception on raise

Using Make $(dir) or $(notdir) on a path with spaces

孤人 提交于 2019-12-03 16:09:24
I'm using code similar to the following in a Makefile: empty:= space:= $(empty) $(empty) path_escape = $(subst $(space),\$(space),$(1)) TOP=$(call path_escape,$(abspath .)) TARGET=$(TOP)/foo $(info TOP='$(TOP)') $(info TARGET='$(TARGET)') all: $(TARGET) $(TARGET): touch '$(notdir $@)' .PHONY: $(TARGET) If I use this in a directory with no spaces, say space-test , it works fine: $ make TOP='/tmp/space-test' TARGET='/tmp/space-test/foo' touch 'foo' However, if I use it in a directory with spaces, say space test , then $(notdir) does the wrong thing: TOP='/tmp/space\ test' TARGET='/tmp/space\