mysql

ZendFramework cuts strings from first non a-z char when inserting to mysql

Hello ! When I insert some data with Zend_Form to database with non a-z characters like chrząszcz it cuts me this string and in database I have saved only chrz. Everyting in MySql is set as utf8_general_ci, when connecting with MySql I call SET CHARACTER SET 'utf8', files are also UTF-8. I have no idea what to do with that. I wrote a...

What's the best way to choose a table name dynamically at runtime?

I am using MySQL Connector/Net and I want to write a query against a table whose name will be specified at runtime. This example is off the top of my head (not tested): public class DataAccess { public enum LookupTable { Table1, Table2, Table3 } public int GetLookupTableRowCount(LookupTable tabl...

php mysql: delete a special character from the database

I sometimes import data from CSV files that were provided to me, into a mysql table. In the last one I did, some of the entries has a weird bad character in front of the actual data, and it got imported in my database. Now I'm looking for a way to clean it up. The bad data is in the mysql column 'email', it seems to be always right in ...

Does MySQL record how often it uses indices?

I've got a table (InnoDB) with a fair number of indices. It would be great to know if one (or more) of these was never actually used. I don't care as much about the disk space, but insertion speed is sometimes an issue. Does MySQL record any statistics on how often it has used each index when running queries? ...

Mysql Date/Datetime columns and Java persistence

I have a Mysql table with DATE column , default '0000-00-00'. If I try to call, for instance, em.find(MyTable.class,pk_value); and it happens to be a record in database with default date value '0000-00-00', an exception is thrown( "java.sql.SQLException: Value ... cannot be represented as java.sql.Date". The same error happens for DateT...

What are good PHP and MySQL type Blogs to read?

I searched and found many topics similar to this on Stackoverflow, but they were all for languages that I do not use. I am interested in reading good blogs with an RSS feed in topics related to PHP, MySQL, Javascript, jQuery. I have a few listed below so far, please share with me any blogs worth reading and subscribing to with any of t...

check if a user registered within the last hour

I have this piece of code to check if a user has already created an account the last hour: $result = mysql_query("SELECT * FROM accounts WHERE registration_ip = '$_SERVER[REMOTE_ADDR]' AND created > ".(time() - 3600)); if (mysql_num_rows($result) > 0) exit('Blablal') It does not exit as I want it do, i can make how many accounts ...

mysql query problem

Hi, I run this query: SELECT v.autor, v.titlu, 'http://85.25.176.18/resursecrestine-download' + v.`link` FROM `video_resurse` v, predicimp3 p WHERE v.titlu = p.titlu ORDER BY v.autor all it's ok. But when i replace "=" with "!=" it takes very long...and instead of results it gives me: #126 - Incorrect key file for table '/tmp/#...

Create PHP array from MySQL column, using auto_increment column as index

Hi, Much like this previous question, I wish to store a MySQL column in a php array (as opposed to storing by row). However, I want the array indexes to match those of the database's primary key. For instance, for the following database: id name 1 Joe 2 Mary 9 Tony $name['9'] == "Ton...

How to time the execution of multiple queries in PHPMyAdmin?

For my search I use multiple queries and I wanted to measure how long it takes mySQL to execute them all. PHPMyAdmin runs all the queries you give it, but It only give the results and execution time of the last one. Is there any way to see a combined execution time without getting out my calculator? :) ...

Limiting while loop

Hi Is there a way to limiting while loops when fetching data from mysql ? $query = "SELECT * FROM `table` WHERE user_id = '$id' ORDER BY `ID` DESC"; $result = mysql_query($query); while ($info = mysql_fetch_assoc($result)) { //stuff } Here i dont want to use mysql's LIMIT function, can i limit while loop other t...

PHP / MySQL formatinng: An example of how this type of data is used?

Hey everyone, Sorry in advance for the kind of odd/vague question :). I've come across this kind of formatting stored in MySQL databases on several occasions now and I'm wondering how the data is used? For example, this line of code was from the bbPress forums plugin bb_message. a:8:{s:9:"max_inbox";i:50;s:13:"auto_add_link";b:1;s:9...

How to add spelling suggestions to PHP/SQL search script

Hey Guys, Creating a search function on my site using php/sql, simple enough - just using a SELECT ALL query on the database using the LIKE clause and echoing the result on the page. My question is, how can I add spelling suggestions in case the user mistyped their search query. Mysql doesn't return anything unless the search term match...

Auto insert values to table from range

Hello ! Is it possible to auto insert values into a table i.e. from 30 to 200 with MySQL statement ? ...

Is there a normalized form for representing several objects from different tables?

For a system I am currently building, the following two scenarios occur: My permissions system is the perennial favorite of attaching permissions to roles, and roles to users, but with a twist: permissions may be applied to any asset at any tier, and there are 4 "Tiers", numbered 0 through 3. As such, the role assignment table is 5 fi...

C# mysql connection practices.

If a C# application connects to a mysql server from a client, how do I store the mysql username/password for the connection? If I have it in a config file or embedded in the source it can be found by reverse engineering. It is not possible to give all users a MySql password. Also, I have a log in for the application. How do I enforce...

Losing Records in a Left join after using Group by

Basically after executing this query: SELECT `view_customer_locations`.customerid, `view_customer_locations`.community_groupid, `view_customer_locations`.community_group, `view_sip_user_agents`.sip_user_agentid, `view_sip_user_agents`.didid, `view_sip_user_agents`.temporary_didid, `view_sip_user_agents`.active_did, GROUP_CONCAT( (IF(...

Finding the performance bottleneck in a Python and MySQL script

I have a script with a main for loop that repeats about 15k times. In this loop it queries a local MySQL database and does a SVN update on a local repository. I placed the SVN repository in a RAMdisk as before most of the time seemed to be spent reading/writing to disk. Now I have a script that runs at basically the same speed but CPU u...

MySql Sql MAX and SUM error

select sum(value) as 'Value',max(value) from table_name where sum(value)=max(sum(value)) group by id_name; The error is: Invalid use of group function (ErrorNr. 1111) Any idea? Thanks. ...

import text file into mysql using jquery

i want to import .txt file values into mysql using php and jquery/Ajax without page refresh. with following format. for example text file is : user@emaill;user name;gender user1@emaill;user name;gender user2@emaill;user name;gender user select file and press Process Button. once it start processing JQUERY/AJAX s...