Step 1: [setup]
a = Aritcle.new(:some_boolean => false)
a.save
write_to_memcache(a.id, Marshal.dump(a))
b = Marshal.load(read_from_memcache(a.id))
If I do:
b.some_boolean = nil
b.save
the some_boolean is not written back to the DB. DB still remains false.
But:
a.some_boolean = nil
a.save
works perfectly. DB is set to NULL.
A...
This query will return a list of project IDs that represent forum threads:
SELECT id FROM `proj_objects` WHERE type='fthread';
This query will subscribe a user (whose ID in the users table is '37') to the forum thread with an ID of '122':
INSERT INTO `subscrips` VALUES ( 37, 122 ) ;
I'd like to insert multiple rows that will subsc...
I have three models linked in this manner: Item->Order->Payment
Order hasMany Item
Order hasOne Payment
Now, I am paginating Items and want to add a condition in it to find only items of that order which has payment of a particular id. I hope that makes sense :P
I added the condition as:
array('Payment.id'=>$id)
but it doesn't w...
I was reading this question about the difference between these 4: http://stackoverflow.com/questions/707874/differences-between-index-primary-unique-fulltext-mysql
However, it is all very abstract and vague to me after reading it. Maybe it would help me understand it more concretely if I had some examples of when I would use it.
For ex...
I'm relatively new to MySQL and I'm having no end of difficulty trying to work out how to do this. I've researched joining and such but I'm not really sure how to apply this.
I have three tables:
Artists Table
ID,
Name,
Description
Albums Table
ID,
Title,
Year,
Artist_ID
Tracks Table
ID,
Title,
Album_ID
Tracks are assigned to albums...
i've got some code that is triggering a syntax error because of some misplaced semicolons. if this was running on the command line, i'd solve this with a delimiter. unfortunately, the jdbc4 driver doesn't seem to recognize delimiters. anyway to get this to run?
delimiter |
CREATE TRIGGER obs_update BEFORE UPDATE ON obs
FOR EACH ROW
BEGI...
I asked a similar question earlier but I'll ask it again in a different way. How can I indent categories and endless sub categories that I have in a select drop down menu using PHP & CSS?
Here is my PHP code.
while (list($id, $parent_id, $category) = mysqli_fetch_array($r, MYSQLI_NUM)) {
// Add to the select menu:
echo '<optio...
I have a query that is producing something like this:
StartTimestamp | EndTimestamp
================================
100 | 450
--------------------------------
150 | 500
I'd like the result to also include the difference between EndTimestamp and StartTimestamp:
StartTimestamp | EndTimestamp | Difference
...
Hi everyone,
I am trying to select entries for a current date but cannot seem to get past the issue of a 1 hour time difference between my timezone and that of the server.
I was able to overcome this by using DATE_ADD() for adding entries but now I need to do the same to SELECT them. I tried inserting SET time_zone = 'America/New_York'...
Say I have 3 queries. Query 1 returns a piece of information that Query 2 and Query 3 needs. Is there a way for Query 2 and Query 3 to access this piece of information from the result of Query 1?
Right now, I have Query 1 executing twice: once in Query 2 and once in Query 3. This doesn't seem efficient to me.
Is there a better way in M...
I'm trying to create a page that tracks some basic user statistics in a database. I'm starting small, by trying to keep track of how many people come using what User Agent, but I've come across a stumbling block. How can I check the User Agent being added to the table to see if it is already there or not?
...
I have data in a sql database that'd I'd like to display on a simple website. The data has an initial question ID "IntQID", which is an auto increment field. Every post has an IntQID. There is another field called "ResID", which is the response ID for a post that is responding to a question. The only data that has no ResID is the initial...
I asked a similar question earlier but I'll ask it again in a different way because I re-worked the code a little.
I was wondering how can I indent categories and endless sub categories that I have in a select drop down menu using PHP & CSS?
Here is my PHP code to display the select drop down.
echo '<select name="parent_id">
<o...
Possible Duplicate:
What is the best PHP programming book?
I am a seasoned developer using microsoft technologies. Licensing and hosting prices are pushing me towards opensource.
I want to develop a website using php apache and my sql, please recommend me a book for learning web development using php apache and my sql.
i wil...
Imagine a blog or cms system (PHP and MySQL). I want to let the user enter some text in a textarea and save it to the database. The type of the field in the database is TEXT.
I want to preserve line breaks and print them later. I know I can do this with PHP's nl2br-function, but how do I protect this string against SQL-injection attack...
I have used Microsoft SQL Server. Is there any management studio for mySql as we have for SQL Server?
...
I have XAMPP on my Ubuntu Lucid system and everything worked fine. But there seems to be some problem now and mysql wouldn't start.
I had tried to recover a few Drupal databases and hence copied the raw files to /opt/lampp/var/mysql folder like all other database folders. And, I guess that could have caused the problem. I am pasting t...
Hi All,
I'm setting up a Wordpress site with the WP ecommerce plugin, I have it all setup and ready but I want to display the categories and products in a tree form (i.e. li tags) within the side menu.
Has anybody done this beofre - don't mind if I have to whack the code in myself.
Any help, much appreciated.
Regards
Shane
...
Hi, I am searching for a PHP function that dynamically generates an XML file with data from a MySQL database. It should also update the database if the XML file is changed.
...
SQLyog automatically appending LIMIT 0, 1000 to all queries in a database which is causing the below query (select next_hi from hibernate_unique_key for update) to fail.
Query : select next_hi from hibernate_unique_key for update **LIMIT 0, 1000**
Error Code : 1064
You have an error in your SQL syntax; check the manual that corresponds...