mysql

What are the better ways with INSERT on relational tables?

I'm experiencing my first mysql INSERT tests and I'm using these tables: table employees -> employee_id -> employee_name -> employee_surname -> employee_url table areas -> area_id -> area_city -> area_address -> area_country table agencies -> agency_id -> agency_name -> agency_url table node_employees -> node_id -> employee_id -> are...

PHP mySQL UPDATE SET LIKE %value

Is there a logical (and possible) way to do something like this? UPDATE $table SET LIKE %_checkbox = '' WHERE id='$id' I have fields like allowed_checkbox and types_checkbox and they are sent to the database script dynamically. Can you use a wildcard when referring to the column name? ...

What are real performance implications of using text instead of varchar types in MySQL?

Is there/has somebody any comparison, personal experience, or guideline when to use the text type instead of a large varchar in MySQL? While most of the entries in my database will be less than 1000 characters, some might take up to 4000 characters or more. What is the limiting length of varchar which makes text a better variant? I do ...

Drupal anonymous user permissions problem

I have been wracking my brain on how to solve this issue for hours now, and I know I'm not the first one to encounter it. I am having trouble granting anonymous users access to node content in Drupal 6.15. I have tried everything, including inserts to MySQL, checking and double-checking every permissions setting available (yes, I have e...

DTS like process for MySQL

I have written a query I want to run against a MySQL db every hour and then email the results to a fixed email address. I know how to do this using DTS on SQL server but have no clue how to do it on MySQL. Does MySQL have an equivalent to DTS. ...

does PHP mysql_real_escape_string() protect database name?

I know that mysql_real_escape_string() prepends backslashes to the following characters: \x00, \n, \r, \, ', " and \x1a I know how this protects a query from injection into something like a variable in a where clause. But here's a scenario I am unsure of: $query = "SELECT * FROM $db WHERE 1"; If $db is taken from a user input, t...

Properly using classes in other classes in php?

Should have asked someone this a long time ago. What is the best way to use other classes within another class? For instance, lets say I have an application class: class Application { public function displayVar() { echo 'hello world'; } } and a database class class Database { // connects to db on construct p...

Setting Up Multiple Classes to Represent Real-World Objects

PHP: If I have a customer class, and the customer can have a car and an invoice, and I want to have separate car and invoice classes, what is the most efficient way of setting them up? So, I have three different classes: customer.class.php customer_car.class.php customer_invoice.class.php What's the best way to set up the relation...

Mysql Table crashed. Please help!!

Out of blue moon, all of sudden, 1 of my database is crashed. This is not the first time, last time I use the "repair table" command and was lucky able to fix it. But it happens again, same table, same error, same solution. Error: 1194: Table 'users' is marked as crashed and should be repaired Do I need to repair my tables every day/w...

SQL Order Alphabetically without preceding zeros for numbers less than 10

Is it possible to order alphabetically in mySQL in the following fashion: A1 A2 A3 A5 A10 A11 A20 A23 A24 Unfortunately the order that I am getting is ordered as seen below here. Notice how any number before A10 aren't grouped together? A1 A10 A11 A12 A2 < A2 A20 A23 A24 A3 < A3 A5 < A5 Note: These alphanumeric strings are a...

MySQL: Is it possible to "INSERT if number of rows with a specific value is less than X"?

To give a simple analogy, I have a table as follows: id (PK) | gift_giver_id (FK) | gift_receiver_id (FK) | gift_date Is it possible to update the table in a single query in such a way that would add a row (i.e. another gift for a person) only if the person has less than 10 gifts so far (i.e. less than 10 rows with the same gift_giver_...

How to retreive row in DB Table just added now in Java

Table id int(11) No auto_increment Change Drop Primary Index Unique Fulltext email varchar(45) latin1_swedish_ci No Change Drop Primary Index Unique Fulltext billpayment tinyint(1) No Change Drop Primary Index Unique Fulltext dispatch tin...

Any simpler / better way of making a mysql singlton db class in php?

Here's the one I'm using: <?php final class Database { private static $oDb; public static function init() { if(self::$oDb == NULL) { self::$oDb = mysql_connect('localhost', 'mysql_user', 'mysql_password') or die(mysql_error()); mysql_select_db('mysql_db_name', self::$oDb) or die (mysql_err...

Unhandled Exception and Mysql.data connection VB

Hi My app connects my server with Mysql.data adapter. most of time it works great but sometimes i get unhandled exception. i am really tired of getting this. here is a screenshot, how can i handle these exceptions ? thx ...

jQuery & PHP - Update current table view with the next records automatically when record(s) in existing view are deleted

Hi all, PLATFORM: PHP, mySQL & jQuery WHAT I HAVE: I have a Database table. Within my application, I am able to fetch all the rows. When I am querying the database, I have set the records fetch limit as 30, but that can be changed via a dropdown list. So consider that I am fetching upto 30 rows of data in a single query and displayin...

MySQL connection parameter to ignore tablename

Is it possible to set a property or variable on MYSQL connect string so that the tablenames are not case sensitive when queries are run on the session? MySQL client/server is running on Linux and storage engine is InnoDB but can be controlled by specifying sessionVariables=storage_engine=MyISAM in the connect string. jdbc:mysql://host:...

Is it possible to issue a select query in mysql without taking any read locks?

It seems that mysql select content (as opposed to e.g. count) queries always take at least a table read lock on myisam tables and a row read lock on innodb tables. Is there a way to issue a select content query in mysql (I could change table type if that's required) without having it to grab any locks? I don't mind if the data returned i...

MySQL tracking system

Hello, I have to implement a tracking system backed up by a MySQL database. The system will track many apps with at least 5 events tracked for each app (e.g. how many users clicked on link x, how many users visited page y). Some apps will have millions of users so a few thousand updates/second is not a far fetched assumption. Another c...

MySQL Table Structure For a Rating System

I want to create a rating system that keeps track of who voted for which article, and how many votes that article received along with the value of each vote. And I was wondering what is the best way to go about this? Here is what I have so far below. CREATE TABLE IF NOT EXISTS `vote` ( `counter` int(8) NOT NULL default '0', `value` i...

MySQL Cardinality vs Auto-Increment Counter

Is the MySQL cardinality number related to the auto-increment counter? ...