I've just discovered an issue where city names that contain accent marks, e.g. La Cañada, Peñasco, etc., won't save to my database. Looking through the answers to another SO question, What is the best collation to use for MySQL with PHP?, I've tried changing both my database and the varchar's collation type from latin1_swedish_ci to utf8_general_ci which still refused the character. I also tried utf8_unicode_ci with a similar result.
I've verified that the save works if I strip out the accent mark on the client side, but ideally I'd like to keep it in there, since that is the real name of the city (according to google maps apis anyway).
What collation types do you use to support ñ?
Additional info: Using MySQL, phpMyAdmin, and CakePHP with an Android app as the client
Thanks for the suggestions so far. I guess this is turning into a CakePHP question now... I noticed that by default utf8 is not enabled, so I enabled it in my app/config/database.php file. I FTPed the file back to the server and tried it again still without any luck. Do I need to redeploy the application to kick off those db config changes, or is there another area of my application I should check? First time CakePHP user here.
Collation is merely the order in which characters are sorted, which is a necessary step in performing comparisons. It has nothing to do with how data is stored (except insofar as a given collation is specific to some encoding).
Character encoding is the mapping of characters to their binary representation for storage, which determines the supported character set.
However, just because a database/table/column are using a particular character encoding is not the end of the story. You must also consider the encoding used within your application and on its interfaces with other components (such as MySQL).
Whilst it's aimed at PHP, UTF-8 all the way through pretty much covers all of the things you need to consider.
Related
I am working on a telehealth device showcase.
I have found Mirth Connect but no able to get hold on it that much. Is there any other api or frees source or library which can be used on our android client to convert xml into HL7 or any other format to HL7.
It seems no one wants to speak up so I'll try. First of all, there are two distinct HL7 formats – HL7v2 and HL7v3. So your first question would be – I have some data stored in the database (in a flat file in the XML format; in a flat file in JSON; etc) and I’d like to map it to HL7v2/HL7v3/CDA/etc.
Since both HL7v2 and HL7v3 cover multiple domains (e.g., Patient Administration, Medical Records, Genomics, etc.) your next question would be to specify what you are trying to achieve. If it’s a single domain solution, i.e., Pharmacy Dispensing System notifications or a full-fledged multi-domain solution.
The next one, what open-source system to use if any – Mirth Connect or something else. It also depends on where the data mapping or transformation is done – on the client side or on the server side (i.e., you can send a request message in your own format and transform it to the HL7 on the server side before passing to other players).
I presume, and I might be incorrect, we are talking about the patient demographic data using HL7v2 running on a patient's mobile phone. The Mirth Connect, as your initial format to HL7v2 translator, may be Ok for prototyping, running as a black box somewhere, but for the real solution on the mobile phone it might be too excessive. If there are quite a few request messages I would build them as my own proprietary code. If your solution is more complex, then it requires reviewing the solution architecture to find out all transformation points and this goes a bit beyond than a discussion on this site.
Again, this is my very subjective opinion.
And the last, but not least, there is an "Unofficial Mirth Connect Developer's Guide" book which may help in initial understanding what the Mirth Connect is capable of.
(Disclaimer: I'm the author of this book, so any comments or suggestions are welcome.)
For creation of some simple HL7 v2 messages you don't need any special libraries or tools or as it is almost simple text piped format (actually it is a binary format but if you take care about correct segment delimiters and don't use other then ASCII characters then it is straightforward to create).
Once you have the HL7 packet you can send it to an IP address with HL7 listening endpoint using the HL7 Minimal Lower Layer Protocol (MLLP).
Some open source code base that might be useful even on Adroid device are Java libraries used by the dcm4chee project.
e.g. the DICOM Clinical Data Manager system - image archive is able to communicate with both DICOM and HL7 systems and internally uses code that translates HL7 v2 messages into XML intermediate representation and back. Look for XSLT (*.xsl) transformation scripts.
I'm trying to extract rdf data from android DB.
It means that I want to get rdf data from contacts DB, callendar DB, and so on directly.
I know that the current android platform have used SQLite DB.
Is it available to extract rdf data?
Surely, I can make the same data typed of rdf manually.
Here, My converting criterion is that the table name means Subject of rdf, the column name means Predicate, and the value means Object.
But the important issue is how to convert data in the existing data in Android DB to RDF data automatically.
I found that the tools such as AndroJena, uJena, Sesame... don't support that functionality.
Help me plz.
PS)
I searched many posts here and I found that someone had stuggled with the similar problem.
He got the solution like below.
First, Copy ur android DB on your own DB in desktop.
Second, Nomalize the copied DB.
Third, Make rdf triples by utilizing the modified DB.
3.1. By referencing such papers titled as RDB to RDF and following the defined converting rules from those, convert data to the data typed of RDF.
Above solution is the only answer?
The general question of converting from a relational DB to RDF was covered by W3C's RDB2RDF working group. This group finished the standards they produced in 2012.
There are two styles, to just directly map to RDF (Direct Mapping) or to map using mapping rules in R2RML. If you convert directly then you can use all your favorite tools to map into the ontology want.
See the Implementation report for a list of implementations at the time it was written. There may be many other bits of software kicking around the web which do this sort of thing, which have been produced more recently or were not spotted then by the group.
The whole RDB2RDF issue is still very much under development. However, D2RQ precedes this discussion and we found this a useful tool to 'automatically' go from RDB to RDF. This only requires a mapping. The code is all in Java, so it is probably possible to adapt it and deploy it to your android phone.
A few notes: D2RQ is not under development anymore (as far as I know) and you still have to make a mapping on how to translate the relational database to rdf.
I am trying to use a database for my application which needs a list of all the words in Arabic language, unfortunately this database is very large in size, more than 200 MB, I've seen that the only solution for such a problem is using a web service or having my database online and download it on first use which is not practical in my case since this is a game and the user can play it while he's disconnected, plus the download size will be large and it will use alot of space on his phone. I couldn't find a way to make the size of my DB reasonable.
My question is if there is a way to shrink the size of the database knowing that all the data stored in it is of the type text.
I've noticed that the keyboard in my phone has an auto-complete feature, where is it getting the list of valid words from? Can i use it for my application?
You'll want to store your words in a prefix tree (or trie). It is a space-efficient structure for this kind of data.
For more info, see: https://gamedev.stackexchange.com/questions/4142/best-way-to-store-a-word-list-in-java-android
your database might have so much extra information included, for example grammar, inflections, comments etc. If this is the case, then re-create your database with only the limited data/columns you need to be used inside phone.
While using MyPHP admin, I edit records in mySQL database that then is updated into my Android application.
If I paste data into one of my table fields, I often get "NULL" displaying in my app. If I paste the web service URL into a browser I still get the NULL value for that particular field.
After further experimenting, I noticed that editing some characters, that tend to be non-standard, the NULL is replaced with my data. This characters seem to be apostrophes, dashes, and brackets...etc.
Is there some way to do a mass conversion so all my data will paste into my table without editing special characters?
I have tried pasting into Notepad and other editors with the same result.
I then tried various means to ensure my tables were using utf8 character set. This yielded no data to my app. (the Browser method still worked). I don't remember adding anything to my app that set the charset.
Any ideas?
Thanks!
Hard to judge without sample data, url, etc. But I would say, given that this data will be displayed on a mobile device, that you probably would need to paste your data into something like TextWrangler, or NotePad++ and you will have to do a regular expression find and replace on all of the special characters. When you're finished, you would have to reimport into your database.
Another solution is to filter out the special characters right on the server. You could use the PHP str_replace function to filter out special characters as well.
I hope this helps!
I am a php/mysql developer learning android. I am creating an android app that receives info from my php app to create list views of different products which will open a web view of that product's detail.
Currently my php cms web application outputs xml lists for an iphone app.... (also, separately outputs html). I have full control of the php app so if there is a better way to output the data for the android app please let me know.
I have created code that reads the xml from the web and creates the list view. The list can be refreshed daily, so the data does not need to be read from the online xml every time the app starts.
So I was thinking to store the data retrieved locally to improve my apps responsiveness. there may be up to 500 product descriptions to be stored at any given time in up to 30 different xml lists. I am starting development with one xml list with about 30 products.
For best performance should i store the product info in a sqlLite db or should i store the actual xml file in the cache/db or some other method like application cache.
I also was think to create the update of the data as a service, would this be a good idea?
The most efficient way to store data is RAM. But if you want to cache it, then the most efficient way is Database.
I recommend you store your data in sqlite android database.
You could also consider zipping you xml for faster network transfer and unzipping through java.util.zip package classes. You could even consider a simpler format for transmitting data, less verbose than xml, using a datainput/outputstream.
(I do that in of my apps and it works great)
Here are some details on data input / output stream method :
imagine a proprietary protocol for your data, only what you need. No tags, no attributes, just raw values in order.
on the client side, get an input stream on your data using URL.getContent() and cast it in input stream.
on the client side still, build a data input stream encapsulating your socket input stream and read data in order. Use readInt, readDouble, readUTF, and so on.
on the client side, from php, you need to find a way to save your data in a format that is compatible with the data format expected by the client. I can't tell much about PHP, I only program using java.
The advantage of this technique is that you save bandwith as there is only data and no verbose decoration due to xml. You should read about java specs to understand how double, int, strings are written in data output stream. But it can be hard using two languages to get the data right.
If php can't save format in a suitable way, use xml, it will be much simpler. First try with just plain xml, then give a try using a zip or tarball or xml file.
But all this is about speed gain during network connection.
The second part of what you have to do is to store each row of your list in a SQL table. Then you can retrieve it pretty fast using a CursorAdapter for your list view (it breaks the charming MVC model but it is quite fast !).
Sorry about this, but it became too long to write as a comment. This is not intended to be an answer to your question, because in my opinion Stéphane answered very well. The best solution is indeed to store the data in an sqlite database. Then you need to create the class to be used as a connection between the data, the database and the app. I don't want to take credit for what is said here already (I, too, voted it up).
I'm concerned with the other suggestion (use of low level raw streams for data manipulation, the list steps on that answer). I strongly recommend you to avoid creating your own proprietary protocol. It goes like this:
I need to exchange data.
I don't want to deal with the hassle of integrating external APIs into my code.
I know I can write two 5 minute routines to read and write the data back and forth.
Therefore, I just created my own proprietary format for exchanging data!
It makes me cry whenever I need to deal with unknown, obscure and arbitrary sequence of data blobs. It's always good to remember why we should not use unknown formats:
Reinventing the wheel is counter-productive. It seems not, but on the middle term it is. You can adapt your project to other mediums (server-side, other platforms) easily.
Using off-the-shelf components help you scale your code later.
Whenever you need to adapt your solution to other technologies and mediums, you'll work faster. Otherwise, you would probably end up with ad hoc code solutions that are not (easily) extensible and interoperable.
Using off the shelf components enables you to leverage advances in that particular technology. That's particularly important when you are using Android APIs, as they are frequently optimized for performance later down the road (See Android's Designing for Performance). Rolling your own standards may result in a performance penalty.
Unless you document your protocol, it's extremely easy to forget the protocol you created yourself. Just give it enough time and it will happen: you'll need to relearn/remember. If you document, then you are just wasting the computational time of your brain.
You think you don't need to scale your work, but chances are you will most of the time.
When you do, you will wish you had learned how to easily and seamlessly integrate well known formats.
The learning curve is needed anyway. In my experience, when you learn, you actually integrate well known formats faster than imagining your own way of doing things.
Finally, trust your data to geniuses that take their lives into creating cohesive and intelligent standards. They know it better!
Finally, if the purpose is to avoid the typical verbosity of XML, for whatever reasons, you have several options. Right now I can think of CSV, but I'm no expert in data storage, so if you're not confortable with it, I'm sure you can find good alternatives with plenty of ready to use APIs.
Good luck!