mysql

Kohana v3 ORM Select and Where clause based on different table.

Hi I need to do something like this: $hours->task->job->where('group_id' , '=' , $num)->find_all(); This would return job information. Is there any way to tell orm to return the information from the $hours table instead? ...

store commas in mysql database

Hello all, I'm trying to store the date in an sql table, but I want it formatted as such: Month day, year October 10, 2010 But whenever I do the sql call, the 2010 gets lost. How can I fix this? $eventdate = "October 10, 2010"; $sql = "INSERT INTO `tims`.`blog` ( `title`, `date`, `post`, `author`, `approved`) \n" . "VALUES...

Table prefix for MySqlMembershipProvider

I have MySqlMembershipProvider working with Asp.Net MVC. My question is how can I configure the table prefix... so instead of 'my_aspnet_' prefix on the tables, I want this to be either none or defined by me. My web.config: <?xml version="1.0"?> <add name="ApplicationServices" connectionString="server=localhost;user id=root;P...

Mysql - "Best Match" search algorithm

Let's assume I have a table full of teachers. every teacher has these parameters: Experience Hourly Cost Distance Last Login Total Rating (like an eBay score given by student) the fact is, that I would avoid to give my users those dropdown menus to choose the sorting option, but i would build a search engine smart enough to compute t...

c# custom datatable view.

Can following thing be done? The red rectangled datatable should be modified as the other row. I am using c#, DataTable with MS-SQL. I want to give shown type of view of second row to the user in a windows. I'll be having at least 500-600 rows like this out of 1000 rows. Which can be shorten down to 1000-600/3 = 800. (Perhabs, I can...

How can I create an efficient MySQL database that auto-complete requests like Google

Hi! I'd like to get some ideas on how I can create an efficient MySQL database that can handle high traffic auto-complete requests like Google's new auto-SERP-update feature. The key to this is, I am trying to take the content of my book and I want to index the text in a way such that the database requests the relevant text in the qu...

Make a single table in mysql read-only

How can I make a single table in mysql read only for a user while he still has write access to other tables in the same db? Additional info I have root access to the server Tables are MyISAM Server version is 5.0.51a-24+lenny2 thanks! ...

CakePHP virtual field that is a sum of three other virtual fields?

I have a virtual field in CakePHP that needs to be a SUM of three very disparate SQL queries in my User model. I'm trying to accomplish this by having a virtual field that is a sum of 3 other virtual fields. var $virtualFields = array ( 'field_one' => 'select coalesce(sum(coalesce(t_a.field, 0)), 0)*10 as field_one from t_a joi...

MySQL multiple variables in LEFT JOIN

I have table dates as following "dates" "one" "two" "three" "four" date1 id1 id2 id3 id4 date2 id3 id1 id4 id2 and a second table id2name "ids" "names" id1 name1 id2 name2 id3 name3 id4 name4 I have a mental block trying to write SELECT * FROM dates WHERE `date`='$date' LEFT JOIN `id2name` O...

Resizing animated images using PHP?

Is there a way I can resize animated images just using PHP without ruining the image and its animation? ...

MySql: remove table rows depending on column duplicate values?

I have a table with year column and this column shouldn't have duplicate values. So I end up with a table with only one 2007 year record for example. So how could I delete those rows that have duplicate year value? Thanks ...

MySQL question: Appending text to a wordpress post, but only if it's in a certain category

I need to amend (via CONCAT, presumably) something to every wordpress post if it belongs to a certain category (say, category ID 7), but I'm struggling to get it to work. To test, I'm first trying to select all the relevant posts. So far, I have the following: SELECT post_title FROM cruise_wp_posts LEFT JOIN cruise_wp_t...

mysql query + performance

is there a performance difference between $a = mysql_query("SELECT * FROM table WHERE id = 1 AND text = 'test'"); and $a = mysql_query("SELECT * FROM `table` WHERE `id` = '1' AND 'text' = 'test'"); ...

Create trigger in PhpMyadmin?

I am using two tables. User table contains the firstname and lastname field and contactinfo is another table contain the field called 'Name' with usertable Id.I want to make a trigger whenever the User tables firstname or lastname is updated I want change this contactinfo's Name to whatever they changed in the User table.Is it possibl...

How to get list of tables, that don`t have a specific column in MySQL

I need to have a list of tables in MySQL, that don`t have a column 'created' or 'modified', so I can add them if non existant. How can I achieve this? Thanks in advance for any help / hint. ...

PHP/MySQL run query on button press/click

Hi, Was wondering if it's possible to run/re-run a mysql query when a button/link is pressed/clicked? Basically, I run a query that limits the results to the first 7, with a button below the results to show more results. When the button is clicked/pressed, I need to re-run the query and set the limit to, say 20. Any help/advice on ho...

Unique slugs that, if fits with slug-1, slug-2... slug-n

I am using only slug to identify a page on the website, like: example.tld/view/this-fancy-slug . This is generated from the title automatically with this function: public static function Normalize($str) { $charset = "UTF-8"; $separator = "-"; $str = strtolower(htmlentities($str, ENT_COMPAT, $charset)); $str = preg_repla...

Zend DB Format Subselect

Hi, I am trying to add a field via a subselect but cant figure out how to format the subquery in Zend DB. E.g. in MySql it looks like this: SELECT a.columnA, b.columnB, **(SELECT c.columnC FROM tableC c WHERE c.test = 1) AS total** FROM tableA AS a INNER JOIN tableB on b.id = a.id The Zend DB format is: ->select() ->from(array('a'=>...

Mysql Connect Two Tables (FK) - Database Design

Hi People, how can I connect the table project_user with the table project_terms in the best way? One Project has different Categorys like 1,2,3,4 The Categorys are stored in the categorys_table But one User maybe are assigned only for the Categorys 1,2 and not 3,4 Should I connect the project_table with the categorys_table too? how ...

Adding the results of multiple SQL selects?

I have three SQL selects, the results of which I need to add together. Two of the three use fairly complex joins. select sum(field_one) from t_a join t_b on (t_a.bid = t_b.id) where t_b.user_id=:id select sum(field_two) from t_c join t_d on (t_c.did = t_d.id) where t_d.user_id=:id select sum(field_three) from t_e where t_e.user_id=:i...