mysql

Convert from using 3 identical SQL params to 1.

I'm using the Java spring framework for security. My pre-existing table layout differs from spring's expected, but I'm allowed to specify a custom authorities-by-username query on the jdbc-user-service. The problem is that this query expects only a single parameter (?) in the SQL statement. Basically, if the user exists in the users t...

How should I store non-tree hierarchical data (i.e. any generic graph)?

I have a site written in PHP. It currently uses MySQL for all of its database needs (I'm open to additional DB technologies). The system's content is interrelated. These relationships can be represented as a graph where vertices are pieces of content and edges are the relationships. I need to be able to traverse that graph. In particu...

how is this table updated if there is no model file?

I'm trying to manually update a db in Spree, but it has no model file. I want to know how to CRUD into the option_values_variants table. The code uses James Golick's Resource Controller, but I want to do it without. models/option_value.rb class OptionValue < ActiveRecord::Base belongs_to :option_type acts_as_list :scope => :option...

MySQL password consistency

In MySQL 5.1 when I type: select Password('test123'); I get password as 41 bytes long. The same, when typed in older MySQL versions, is 16-bytes long. I need to store 16-byte long passwords, so is there any way to specify length (16-bytes) while retrieving/encrypting the password? ...

Searching Database PHP/MYSQL Question

Right now I'm just using a simple WHERE name LIKE '%$ser%' But I'm running into an issue - say the search is Testing 123 and the "name" is Testing, it's not coming back with any results. Know any way to fix it? Am I doing something wrong? ...

How is utf8 data supposed to look when stored in a database?

I need a bit of help understanding how utf8 data is supposed to look when stored inside the database. I'm using mysql and php, the database is set to utf8, the collation on the column "p_name" is set to "utf8_unicode_ci". When I insert the data I pass it through this function function convert_charset($in_str) { $cur_encod...

Reading UTF-8 data from MySQL shows ? insted of ı

Here is how I read the data: <?php $id = $_GET["id"]; $number = mysql_real_escape_string($id); $result = mysql_query('SELECT * FROM `mystory` where `id` = ' . "$number" . ' LIMIT 1'); $row = mysql_fetch_assoc($result); echo $row['story']; ?> The data is encoded as utf8_bin. Insted of ı PHP outputs ? Why is that? What I'm doing wrong...

Mysql Fulltext Search

This query is running only for data available in t1.ads_category, not for the other two columns: SELECT t1.id, t1.ads_type, t1.ads_category, t1.ads_subcat, t1.ads_title, t1.ads_title, t1.ads_description, t1.ads_city, t1.ads_location, t2.ads_image, t2.ads_activate, ...

PHP MYSQL if null statement.

I need a way to do this, If a mysql query dosn't retrieve any data, something happens. Here's an example. $color="red"; $query = mysql_query("SELECT * FROM people WHERE shirt='$color'"); if($query = null){ echo 'No people wearing '.$color' shirts available.'; } ...

Creating a custom forum, help with building a query that counts posts in a categories etc.

So my database setup is fairly simple. I have a forum_cat table (a forum category) and forum_post table. The forum_post has a field fk_forum_cat_id which ties each forum post to a category. Each forum_post also has a field fk_parent_forum_post_id which basically says it belongs to an original post. Further more, there is a date_added...

very large mysql full-text database - slow with large search results

I have a 9-million-row table in a MySQL database that needs full-text search against three of its fields. We thought the hard part would be finding that one-in-9-million row, but that's not what we ran up against. Our problem is that one of them is a "location" field, so searches for "poughkeepsie" come back super-fast, but searches fo...

Codeigniter: multiple Active Record calls vs lumping together and breaking models

If I have an event/function that requires changing a lot of different variables in my Active Record, should I directly access them and change them all at once from my library or have the library do multiple model calls? The data I want to change is spread over a handful of different mysql tables but some are within the same table. I'm...

Can something "bad" happen via img src?

I know, I know, title is quite bad, but I'll try to explain what I mean here. So, I ask my members to show their photos. They upload it somewhere, then paste their photos' URL into input and I save it to my database (MYSQL). Then, the photo is being seen on their profiles. I get the URL from database and do something like that: <img src=...

how to trace mysql trigger or help with this one.

Hello everyone, Is there a way to trace MySql triggers? I am stuck with the following one. I want to calculate a column before insert concatenating two other columns, but there is problem calculated value is always null, i also need to check if one column has comma separated values, in that case i only want the first one, here is the ...

Fetching top 5 records of maximum salary

I have 3 columns with id,usrnameand salary. I want to find maximum salary of 5 records. How will i write query in mysql ? ...

session data not being written to database

The site I'm renovating writes session data to their database using the session_set_save_handler function as follows: session_set_save_handler (array(&$ses_class, '_open'), array(&$ses_class, '_close'), array(&$ses_class, '_read'), array(&$ses_class, '_writ...

MySQL updating 'categories' linking table

I have a table that holds bibliography entries, with a bibID primary key. I also have a table that holds a list of categories that can be assigned to the bibliography entries with a categoryID primary key. A table links these two tables as bibID:categoryID, so that each bibID can be associated with multiple categoryIDs. Categories assoc...

SQL INSERT: skip values allready present

Hi, I'm trying to add sequence of tags to a list subjects. I wouldn't make unique tag column field because I may have the same duplicate depending by the user language like in the example table_houses id name location 1 Victoria's Home New York 2 Black Mesa Lab New Mexico ...

Selecting entries by date - >= NOW(), MySQL

Hi everyone, I have a Calendar of Events table and I would like to select events with dates equal to or greater than today. When I use the following SELECT statement, it only retrieves events in the future (> NOW()): <?php $db->query("SELECT * FROM events WHERE event_date >= NOW()"); ?> How would I go about selecting all events t...

Do I've to free mysql result after storing it?

Hi, I was wondering whether or not I've to call the $stmt->free_result() for after I've stored it's result with $stmt->store_result()? Could I rather just call $stmt->close() on the end? The reason why I'm asking it is because when I call the $stmt->num_rows I've to call the $stmt->store_result() as said here: http://www.php.net/manual...