How can i check the result of my query? I try this, but when the result is empty – error doesn’t shows. Answer Note that sqlite_fetch_array() returns a result handle, not the number of rows, so you should not compare it against zero: This function will return a result handle or FALSE on failure. Use sqlite_num_rows() to determine the number
Tag: sql
selecting unique values from a column
I have a MySQL table which contains the following type of information: Here is an example of a script I use to get data from this table: This script displays every date from the table, e.g. I would like to only display unique dates, e.g. Answer Use the DISTINCT operator in MySQL:
Select Random Row from SQL Using PHP
I want to request 5 random rows from my SQL table using php. for instance, i need to: Answer Edit: For what its worth, Please note that using rand() on a table with large number of rows is going to be slow. This can actually crash your server. Some Solution: MediaWiki uses an interesting trick (for Wikipedia’s Special:Random feature): the
Search with full name instead of just first name or last name
I am developing an API built with PHP and Codeigniter and I use MySQL as database. I have a user table called Users which contains the following columns: How can a user search this table using a full name? For example it works fine to search either by Martin or Smith, but not Martin Smith. This is the query I
IMDB to MySQL: Insert IMDB data into MySQL database
I’m looking for a solution to import all the IMDB data into my own MySQL database. I’ve downloaded all the IMDB data files from their homepage which are all in the file format *.list (in Windows). I want to retrieve and that information and insert it correctly into my MySQL database so I can do some test and query searches.
How to optimize a query with MySQL multi-query?
I need to optimize a script for high performance so the question is how can I add MySQL multi-query to this code? Answer If you’re using mysqli or PDO already, you should be using prepared statements for your queries since they are supported. This will also have a slight increase in performance since the entire query doesn’t need to be
Purpose of Secondary Key
What is the purpose of the Secondary key? Say I have a table that logs down all the check-ins (similar to Foursquare), with columns id, user_id, location_id, post, time, and there can be millions of rows, many people have stated to use secondary keys to speed up the process. Why does this work? And should both user_id and location_id be
Query for maximal number in an INT column works well in phpmyadmin, but not in php code
I am trying to grab the MAX number of an INT column. When I run the query in phpmyadmin, it works fine. But when I put it in my PHP code, it keeps returning 0. I think my problem is I dont know how to grab it from the query properly. Specifically im using mysql_result, but after reading its syntax,
How to make “LIKE” query work in MongoDB?
I have a list of street names and I want to select all that start with “Al”. In my MySQL I would do something like How about MongoDB using PHP? Answer Use a regular expression: or: http://www.mongodb.org/display/DOCS/Advanced+Queries#AdvancedQueries-RegularExpressions Turning this into PHP:
Doctrine 2: Update query with query builder
Hi I’ve got the following query but it doesn’t seem to work. This returns the following error message: Fatal error: Uncaught exception ‘DoctrineORMQueryQueryException’ with message ‘[Semantical Error] line 0, col 38 near ‘testusername WHERE’: Error: ‘testusername’ is not defined.’ in … I would be glad of any help Answer I think you need to use ->set() It’s much safer to