glob() sort my files as follows:
ABC_file.pdf
DEF_file.pdf
GHJ_file.pdf
ABC_file.zip
But I want sort them only by name (not by name and extension too):
ABC_file.pdf
ABC_file.zip
DEF_file.pdf
GHJ_file.pdf
How to do?
Thanks in advance
Try this:
glob($fileMask, GLOB_NOSORT);
According the PHP manual:
GLOB_NOSORT - Return files as they appear in the directory (no sorting)
Related
I have freepbx, Asterisk version 13.32.0 built by mockbuild # jenkins7.
We need to include into queue_log file additional field with CallerID number. How can i do this?
Right now I have a table on mysql - queue_log, but I want to see the Callerid number. Is it possible?
Thanks!
ENTERQUEUE event's data2 is callerid.
There are no ways add more info, except you can use QueueLog app to add custom info.
I tried to join two csv file based on id with respect to the below reference.
How to join two CSVs with Apache Nifi
i'm using NiFi-1.3.0
Now i have two csv files.
1.custom.csv
No,Name,ID,Age
1,Hik,2201,33
2,Kio,3300,22
2.gender.csv
ID,Name,Sex
2201,Hik,Male
3300,Kio,Female
I try to combine those tables with "ID" like following endresult.
No,Name,Sex,ID,Age
1,Hik,Male,2201,33
2,Kio,Female,3300,22
I have using following processor structure.
GetFile-SplitText-ExtractText-LookUpRecord-PutFile
In that lookup record i have configured
RecordReader = "CSVReader"
RecordWriter="FreeFormTextRecordSetWriter"
LookUpService="SimpleCSVFileLookUpService"
ResultRecordPath-->/Key
key-->/ID
In that LookUpService i have given path of the "gender.csv" and setted LookUpKeyColumn and LookUpValueColumn to be "ID".
In that FreeFormTextRecordSetWriter i have given text value"${No},${Name},${ID},${Age},${Sex}"
It yields below result only.
No,Name,ID,Age,
1,Hik,2201,33,
2,Kio,3300,22,
It doesn't have "sex" column.
I think i haven't configured correctly.
i don't know how to use ResultRecordPath & one dynamic attribute(Key) specification in LookUpRecord?
Can anyone guide me to solve my issue?
This was asked and responded to on the apache nifi mailing list.
https://lists.apache.org/thread.html/5041018de5a5be773055bb2709427eed4131c3923262b55051fb1324#%3Cusers.nifi.apache.org%3E
What's wrong with this code, I want to insert an image to table, but when I was executed this code the result of image field is NULL.
I try with MySQL Workbench executing:
CREATE TABLE image(keyh int, img blob);
INSERT INTO image VALUES(1, load_file('d:\Picture\cppLogo.png'));
To use this function, the file must be located on the server host, you
must specify the full path name to the file, and you must have the
FILE privilege. The file must be readable by all and its size less
than max_allowed_packet bytes. If the secure_file_priv system variable
is set to a nonempty directory name, the file to be loaded must be
located in that directory.
If the file does not exist or cannot be read because one of the
preceding conditions is not satisfied, the function returns NULL.
http://dev.mysql.com/doc/refman/5.7/en/string-functions.html#function_load-file
What can you do?
Check which user mysql is running with, and make sure the file is readable by that user. Make sure the security settings allow the file to be read and it is not of greater size than max_allowed_packet.
See SHOW VARIABLES LIKE 'max_allowed_packet'.
For me, it looks like the file is on your localhost and you try to upload it. This is not possible using LOAD_FILE(). The file must be already on the server.
The issue can also be caused by your windows directory seperator character \ (like RiggsFolly said), which is used for escaping instead, switch to unix style / then:
LOAD_FILE('D:/Picture/cppLogo.png')
Or your Image is of greater filesize than a BLOB field can hold, like Balazs Vago said.
i was found the correct syntax is following this:
C:/wamp/binsql5.5.20/data/56VRLRFE.jpg'
not this
C:\wamp\binsql5.5.20\data\56VRLRFE.jpg'
thanks guys for all your Answer :D
Open your MySql Command Line Client and login with root user and type
mysql> SHOW VARIABLES LIKE "secure_file_priv";
this will show you the secure path used by MySql to access the files. something like
+------------------+-----------------------+
| Variable_name | Value |
+------------------+-----------------------+
| secure_file_priv | /var/lib/mysql-files/ |
+------------------+-----------------------+
you can either paste files inside this folder or change the "secure_file_priv" variable value to "empty string" so that it can read file from anywhere.
On Windows the fundamental problem is that MySql, by default, runs as a Windows service under the Network account which means that there are only a few file locations the server can access. Thus for load_file to work, the file must be placed in a folder on the server which can be read by the service. There seems to be no documentation on this. In my investigation the only folder that works with load_file is C:\ProgramData\MySQL\MySQL Server 8.0\Uploads
Run a query to test the load...
select load_file('C:\\ProgramData\\MySQL\\MySQL Server 8.0\\Uploads\\1.txt') ;
Note on windows you have to use either double \ or / to separate the path elements. This will return NULL on failure, otherwise the contents of the file.
Assume now a table named db.image with columns source and image. Source is character and image is blob. The command to load a.jpg into the table would be
insert into db.image (source,image) values ('a.jpg',load_file('c:/programdata/mysql/mysql server 8.0/uploads/a.jpg'));
Store Directly Without folder name for example-
create table myimg(id int, image mediumblob);
insert into myimg values(101, load_file("E://xyz.png"));
I need help with Get Statements and Running on a site on PHP
I have this a my PHP code
This is how I save it but it only saves username ...
http://example.com/NC0.php?U=namehere
I have tried this below but it doesn't work
http://example.com/NC0.php?U=namehere?P=passhere
How can I make it like........ NC0.php?U=namehere?P=passhere
or something similar thanks!!!
You are using the ? multiple times. It is meant to start the query! To have multiple parameters in the URL you use the & symbol to differentiate the parameters.
For example,
http://example.com/NC0.php?U=namehere&P=passhere
I'm trying to create a text file that contains the value of a custom field I added on redmine. I tried to get it from an SQL query in the create method of the project_controller.rb (at line 80 on redmine 1.2.0) as follows :
sql = Mysql.new('localhost','root','pass','bitnami_redmine')
rq = sql.query("SELECT value
FROM custom_values
INNER JOIN projects
ON custom_values.customized_id=projects.id
WHERE custom_values.custom_field_id=7
AND projects.name='#{#project.name}'")
rq.each_hash { |h|
File.open('pleasework.txt', 'w') { |myfile|
myfile.write(h['value'])
}
}
sql.close
This works fine if I test it in a separate file (with an existing project name instead of #project.name) so it may be a syntax issue but I can't find what it is. I'd also be glad to hear any other solution to get that value.
Thanks !
(there's a very similar post here but none of the solutions actually worked)
First, you could use Project.connection.query instead of your own Mysql instance. Second, I would try to log the SQL RAILS_DEFAULT_LOGGER.info "SELECT ..." and check if it's ok... And the third, I would use identifier instead of name.
I ended up simply using params["project"]["custom_field_values"]["x"] where x is the custom field's id. I still don't know why the sql query didn't work but well, this is much simpler and faster.