DQL searching MD5 string? - doctrine-orm

How do I search my database using DQL for a MD5 string.
I'm using doctrine and want to write the following query in DQL.
SELECT * FROM club_members WHERE md5( CONCAT('secret_key',id)) = '8e801b9cd9b38c142472d5fc5238f538'
I tried
$dql = "SELECT c FROM models\Club_members c WHERE md5( CONCAT('".$secret_key."',c.id)) = '8e801b9cd9b38c142472d5fc5238f538'";
but get a fatal error
Fatal error: Uncaught exception 'Doctrine\ORM\Query\QueryException' with message '[Syntax Error] line 0, col 52: Error: Expected known function, got 'md5'' in //application/libraries/Doctrine/ORM/Query/QueryException.php:42 Stack trace: #0 //application/libraries/Doctrine/ORM/Query/Parser.php(396): Doctrine\ORM\Query\QueryException::syntaxError('line 0, col 52:...') #1 //application/libraries/Doctrine/ORM/Query/Parser.php(2778): Doctrine\ORM\Query\Parser->syntaxError('known function', Array) #2 //application/libraries/Doctrine/ORM/Query/Parser.php(2311): Doctrine\ORM\Query\Parser->FunctionDeclaration() #3 //application/libraries/Doctrine/ORM/Query/Parser.php(2279): Doctrine\ORM\Query\Parser->ArithmeticPrimary() #4 //application/libraries/Doctrine/ORM/Query/Parser.php(2247): Doctrine\ORM\Query in //application/libraries/Doctrine/ORM/Query/QueryException.php on line 42
Any suggestions?

MD5 is not included into standard Doctrine, you need to install MD5 extension: https://github.com/beberlei/DoctrineExtensions/blob/master/lib/DoctrineExtensions/Query/Mysql/Md5.php

Related

Rmarkdown addin for creating new post not working

Today I wanted to create a new post for my website (built using blogdown), but the New Post addin doesn't seem to work.
When I select "New Post" or run
blogdown:::new_post_addin()
I get an error:
Error in FUN(X[[i]], ...) : subscript out of bounds
In addition: Warning messages:
1: In value[[3L]](cond) :
Cannot parse the YAML metadata in 'content/photo.md': Scanner error: while scanning an alias at line 3, column 1 did not find expected alphabetic or numeric character at line 3, column 2
2: In value[[3L]](cond) :
Cannot parse the YAML metadata in 'content/research.md': Scanner error: while scanning an alias at line 4, column 1 did not find expected alphabetic or numeric character at line 4, column 2
I am not sure what the additional warnings are about, but I want to focus on the main error. Here are details returned by traceback():
> traceback()
10: lapply(meta, `[[`, i)
9: unlist(lapply(meta, `[[`, i))
8: blogdown:::collect_yaml()
7: eval(exprs[i], envir)
6: eval(exprs[i], envir)
5: sys.source(pkg_file("scripts", file), envir = new.env(parent = globalenv()),
keep.source = FALSE)
4: xfun::in_dir(site_root(), expr)
3: in_root(sys.source(pkg_file("scripts", file), envir = new.env(parent = globalenv()),
keep.source = FALSE))
2: source_addin("new_post.R")
1: blogdown:::new_post_addin()
Interestingly, when I run this command:
blogdown::new_post(title, ext = '.md')
it works fine and I can create a new post. I updated both blogdown and hugo but to no avail. Could someone help me understand what this error is about? Other addins (such as Insert Image) work fine.
As requested, the githup repo is https://github.com/msmielak/msmielak.github.io and the dput() output is below:
>dput(blogdown:::scan_yaml())
list(`content/about.md` = "<img align=\"right\" src=\"/./about_files/rsz_screenshot_2020-12-28_une_home.png\" alt=\"\" width=\"100px\"/>\n\n**2014-**\nPhD candidate at the School of Environmental and Rural Sciences University of New England in Armidale, Australia.",
`content/code.md` = NULL, `content/contact.md` = NULL, `content/photo.md` = NULL,
`content/post/2021-03-29-extracting-date-and-time-from-photo-using-ocr-engine-tesseract/index.md` = list(
title = "Extracting date and time from camera trap photos using R and tesseract",
author = "", date = "2021-03-29", slug = list(), categories = c("code",
"R"), tags = c("R", "code", "camera trap", "OCR"), description = "",
featured = "", featuredalt = "", featuredpath = "", linktitle = ""),
`content/research.md` = NULL, `content/technology.md` = NULL)
Warning messages:
1: In value[[3L]](cond) :
Cannot parse the YAML metadata in 'content/code.md': Parser error: did not find expected <document start> at line 3, column 67
2: In value[[3L]](cond) :
Cannot parse the YAML metadata in 'content/photo.md': Scanner error: while scanning an alias at line 3, column 1 did not find expected alphabetic or numeric character at line 3, column 2
3: In value[[3L]](cond) :
Cannot parse the YAML metadata in 'content/research.md': Scanner error: while scanning an alias at line 4, column 1 did not find expected alphabetic or numeric character at line 4, column 2
The YAML metadata of the file content/about.md seems to be invalid. Normally YAML metadata should be of the form:
---
tag1: value1
tag2: value2
---
Update: with the dev version of blogdown (>= v1.2.4), the error will no longer occur. What's more, blogdown::check_site() can detect this problem and suggest users fix the problematic YAML metadata.
remotes::install_github('rstudio/blogdown')

Opencart Database tables missing

I keep getting this error when trying to add a product in OpenCart 1.5.6 - it only started happening recently and I'm trying to trace back anything which might have been installed or uninstalled.
This is the error I seem to be getting. I was wondering if someone might know what the table is related to? I can then uninstall and reinstall.
Fatal error: Uncaught exception 'ErrorException' with message 'Error: Table 'DBName.shop_profile' doesn't exist<br />Error No: 1146<br />SELECT `p`.`profile_id`, `p`.`sort_order`, `pd`.`name` FROM `shop_profile` AS `p` JOIN `shop_profile_description` AS `pd` ON `pd`.`profile_id` = `p`.`profile_id` AND `pd`.`language_id` = 1 ORDER BY p.sort_order ASC ' in /system/database/mysqli.php:41 Stack trace: #0 /system/library/db.php(20): DBMySQLi->query('SELECT `p`.`pro...') #1 /admin/model/catalog/profile.php(34): DB->query('SELECT `p`.`pro...') #2 /admin/controller/catalog/product.php(868): ModelCatalogProfile->getProfiles() #3 /admin/controller/catalog/product.php(64): ControllerCatalogProduct->getForm() #4 [internal function]: ControllerCatalogProduct->insert() #5 /system/engine/front.php(42): in /system/database/mysqli.php on line 41

Get substring from Oracle message error

How can I retrieve from this
ERROR at line 12:
ORA-00904: "REPLAC": invalid identifier
that what goes from ORA and its colon, so for this example
"REPLAC": invalid identifier
Test working here .*ORA[\d\w\-]*\:(.*) shall get you the error

Django + Postgres: Trying dump and restore database, but are seeing ERROR: relation "*_id_seq" does not exist for all sequence tables

I am trying to move a database from a virtual machine (docker-machine) over to a database server on azure. I am first using the following command to dump the database to a local file:
pg_dump -h <virtual-machine-ip> -U <username> postgres > dump.sql
Then I try to restore it on the new server:
psql -h <database-server-ip> -U <username> -d <new_database_name> -f dump.sql
Which produces a lot of errors (example below):
SET
SET
SET
SET
SET
SET
SET
SET
COMMENT
CREATE EXTENSION
COMMENT
SET
SET
SET
CREATE TABLE
ALTER TABLE
psql:dump.sql:66: ERROR: syntax error at or near "AS"
LINE 2: AS integer
^
psql:dump.sql:69: ERROR: relation "auth_group_id_seq" does not exist
psql:dump.sql:75: ERROR: relation "auth_group_id_seq" does not exist
CREATE TABLE
ALTER TABLE
psql:dump.sql:101: ERROR: syntax error at or near "AS"
LINE 2: AS integer
^
psql:dump.sql:104: ERROR: relation "auth_group_permissions_id_seq" does not exist
psql:dump.sql:110: ERROR: relation "auth_group_permissions_id_seq" does not exist
CREATE TABLE
ALTER TABLE
psql:dump.sql:137: ERROR: syntax error at or near "AS"
LINE 2: AS integer
^
psql:dump.sql:140: ERROR: relation "auth_permission_id_seq" does not exist
psql:dump.sql:146: ERROR: relation "auth_permission_id_seq" does not exist
CREATE TABLE
ALTER TABLE
psql:dump.sql:175: ERROR: syntax error at or near "AS"
LINE 2: AS integer
^
psql:dump.sql:178: ERROR: relation "clients_client_id_seq" does not exist
psql:dump.sql:184: ERROR: relation "clients_client_id_seq" does not exist
CREATE TABLE
ALTER TABLE
psql:dump.sql:214: ERROR: syntax error at or near "AS"
LINE 2: AS integer
I have tried reading the docs on pg_dump, but whatever I do, I get the same result...
Any idea of what is happening here? Have I missed some options that should have been included in the dump command?
Thank you very much!
As Valdemar stated, the AS integer was introduced in 10.x, and is not backwards-compatible. If you are able to regenerate the dump through the command-line interface (pg_dump), here are the steps I would advise :
Dump the database in plain-text format using the -Fp (or --format=plain)
Edit the generated file to get rid of the AS integer statements
Import the altered file in your destination database
TL;DR
pg_dump -h <virtual-machine-ip> -U <username> -Fp postgres > dump.sql
sed 's/AS integer//' dump.sql > altered_dump.sql
psql -h <database-server-ip> -U <username> -d <new_database_name> -f altered_dump.sql

pig REPLACE gives error

Let's assume that my file is named 'data' and looks like this:
2343234 {23.8375,-2.339921102} {(343.34333,-2.0000022)} 5-23-2013-11-am
I need to convert the 2nd field to a pair of coordinate numbers. So I wrote the follwoing code and called it basic.pig:
A = LOAD 'data' AS (f1:int, f2:chararray, f3:chararray. f4:chararray);
B = foreach A generate STRSPLIT(f2,',').$0 as f5, STRSPLIT(f2,',').$1 as f6;
C = foreach B generate REPLACE(f5,'{',' ') as f7, REPLACE(f6,'}',' ') as f8;
and then used (float) to convert the string to a float. But, the command 'REPLACE' fails to work and I get the following error:
-bash-3.2$ pig -x local basic.pig
2013-06-24 16:38:45,030 [main] INFO org.apache.pig.Main - Apache Pig version 0.11.1 (r1459641) compiled
Mar 22 2013, 02:13:53 2013-06-24 16:38:45,031 [main] INFO org.apache.pig.Main - Logging error messages to: /home/--/p/--test/pig_1372117125028.log
2013-06-24 16:38:45,321 [main] INFO org.apache.pig.impl.util.Utils - Default bootup file /home/isl/pmahboubi/.pigbootup not found
2013-06-24 16:38:45,425 [main] INFO org.apache.pig.backend.hadoop.executionengine.HExecutionEngine - Connecting to hadoop file system at: file:///
2013-06-24 16:38:46,069 [main] ERROR org.apache.pig.tools.grunt.Grunt - ERROR 1000: Error during parsing. Lexical error at line 7, column 0. Encountered: <EOF> after : ""
Details at logfile: /home/--/p/--test/pig_1372117125028.log
And this is the details of the pig_137..log
Pig Stack Trace
---------------
ERROR 1000: Error during parsing. Lexical error at line 7, column 0. Encountered: <EOF> after : ""
org.apache.pig.tools.pigscript.parser.TokenMgrError: Lexical error at line 7, column 0. Encountered: <EOF> after : ""
at org.apache.pig.tools.pigscript.parser.PigScriptParserTokenManager.getNextToken(PigScriptParserTokenManager.java:3266)
at org.apache.pig.tools.pigscript.parser.PigScriptParser.jj_ntk(PigScriptParser.java:1134)
at org.apache.pig.tools.pigscript.parser.PigScriptParser.parse(PigScriptParser.java:104)
at org.apache.pig.tools.grunt.GruntParser.parseStopOnError(GruntParser.java:194)
at org.apache.pig.tools.grunt.GruntParser.parseStopOnError(GruntParser.java:170)
at org.apache.pig.tools.grunt.Grunt.exec(Grunt.java:84)
at org.apache.pig.Main.run(Main.java:604)
at org.apache.pig.Main.main(Main.java:157)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.hadoop.util.RunJar.main(RunJar.java:197)
================================================================================
I've got data like this:
2724 1919 2012-11-18T23:57:56.000Z {(33.80981975),(-118.105289)}
2703 6401 2012-11-18T23:57:56.000Z {(55.83525609),(-4.07733138)}
1200 4015 2012-11-18T23:57:56.000Z {(41.49609152),(13.8411998)}
7104 9227 2012-11-18T23:57:56.000Z {(-24.95351118),(-53.46538723)}
and I can do this:
A = LOAD 'my_tsv_data' USING PigStorage('\t') AS (id1:int, id2:int, date:chararray, loc:chararray);
B = FOREACH A GENERATE REPLACE(loc,'\\{|\\}|\\(|\\)','');
C = LIMIT B 10;
DUMP C;
This error
ERROR 1000: Error during parsing. Lexical error at line 7, column 0. Encountered: <EOF> after : ""
came to me because I had used different types of quotation marks. I started with ' and ended with ยด or `, and it took quite a while to find what went wrong. So it had nothing to do with line 7 (my script was not so long, and I shortened data to four lines which naturally did not help), nothing to do with column 0, nothing to do with EOF of data, and hardly anything to do with " marks which I didn't use. So quite misleading error message.
I found the cause by using grunt - pig command shell.