database

Creating AR model for Drupal database

how do I change my activerecord model default behavior for the find method? For example, i want to search for all books inside drupal nodes database, but drupal uses only one table for all data, and uses the 'type' column to find out the type class Book < ActiveRecord::Base set_table_name 'node' def find(*args) :conditions => {...

Tricky SQL for a smart search

I am using a form through a PHP CMS system, that defines custom fields and such. One of the custom fields allows for an input field which does a smart search. What this means is that when you start typing, it shows the records that match, quite similar to google suggest. The smartsearch input field relies on a stored mysql search, and ...

trouble with automatically generated sql query

I am having trouble with an automatically generated SQL query, that is based on several smaller queries stored in a table, and combined with what the user inputs. I will show the inputs for a query that works, and then the query itself. I will then show my inputs, and the query that fails. If someone could point me what input I have u...

Best way to store a many-to-many relationship in MySQL?

Let's say I have a simple database with tables 'posts' and 'tags'. Posts can have many tags and tags can belong to many posts. What is the best way to structure the database? I thought of using a list/serialize: tags idx tag_id, str tag_name posts idx post_id, str title, list tag_ids OR having another table with the associations. Pr...

error while trying to push database to heroku

I am trying to do a $heroku db:push this is the error I get C:/Ruby/lib/ruby/gems/1.8/gems/rack-1.2.1/lib/rack/utils.rb:138:in `union': can't convert Array into String (TypeError) from C:/Ruby/lib/ruby/gems/1.8/gems/rack-1.2.1/lib/rack/utils.rb:138 from C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in ...

Need help with a really simple database read and write

I'm using a SQL database to store a single float value, and I'm really having trouble getting my brain around everything that needs to be done to make it work. I've been reading the NotePad tutorial Google provides for a few days now and Googling around but it just isn't clicking in my head. Could anyone explain to me (no code needed) ...

Tracing an ajax error to a sql query

I am working within the confines of CMS software, that automatically generates a query for use in a google suggest like input field. The provided fields works fine, with the query they use which uses an inner join over two tables. I am trying to make a query which will grab information from just one table, and will returns results on e...

SQL query and stored procedure not producing desired results

I have this table and Stored proc function: Table: CREATE TABLE _DMigNumbers( Number numeric(20,0) NOT NULL PRIMARY KEY ); INSERT INTO _DMigNumbers VALUES(0) Stored proc function: CREATE FUNCTION read_and_increment() RETURNS NUMERIC(20,0) BEGIN DECLARE @number_just_read NUMERIC(20,0); SELECT number INTO @number_just_r...

[database design] table for even connections

id | element ---------- 1 | Milk 2 | Bread 3 | Butter Milk and Butter have "connection". And Bread and Butter have "connection". These are even connection, not parent-child. How can i display them? id1 | id2 ---------- 1 | 3 2 | 3 yes, but id1 | id2 ---------- 3 | 1 3 | 2 also right, there are no first and second....

SQLite supported database formats?

Hi guys, was just wondering what formats of databases can SQLite support. i only know of .sql. Is .mdf supported? ...

Why is my insert not working in php?

I have an insert statement I am querying to the DB. $notes_sql = 'INSERT into notes SET order_id = "'.$_GET['order_id'].'", date_added = "'.$date_added.'", note_message = "'.$_SESSION['note_message'].'"'; $notes_result = $conn->query($notes_sql) or die(mysqli_error($conn)); I know the sql sta...

IndexDB, WebSQL in 4 Months

Hi All, I've got a bit of a problem, I'm about to start a 4-6 month project which will need offline support. AppCache is awesome and accepted as the standard but the big browsers are still undecided about the database implementation with Opera, Safari and Chrome opting for WebSQL (SQLite) and Mozilla and supposedly IE backing IndexDB. ...

do I need to store domain names to md5 mode in database??

I had a feeling that searching domain names taking time more than as usual in mysql. actually domain name column has a unique index though query seems slow. My question is do I need to convert to binary mode?? say md5 hash or something?? ...

International Replication Timestamps

Hi all, My scenario is as follows. I have a client and server. The client pulls data from the server by using a value that is stored locally called LastReplication. This value is passed to the server whenever a request for replication data is made and the server compares it to a field in my database called LastUpdated and returns and r...

Storing time values in a database and getting the difference between two time fields

I am working on an application the stores time values in a database e.g Expected time of Arrival and actual time of arrival. What is the best way of storing these fields in a database? What SQL query can I use to obtain the time difference between the two fields? ...

Suppose I want to create a "stored function" for MYSQL. Where do I wrote it? Which file?

Of course, I could go into mysql console and type the Function. But what if I want to store it for future use? What do I do? ...

Setting multiple fields in a database, from just one field...

I am working in the confines of a CMS system, which defines certain fields which can be used to make forms for use within the application in PHP. I am making use of the inputSmartSearch field, which is basically similar to Google suggest. It allows me to define an SQL query, and then displays records that match as I type in my search. ...

Version control of databases

I am curious if there are any solutions out there, preferably free, that can have a central database to publish data to in a versioned manner. For example, Client 1 decides to edit a persons profile so it gets a local copy on its machine to make changes to. When they are happy with there edit they publish the results to the central dat...

Why does VARCHAR need length specification?

Why do we always need to specify VARCHAR(length) instead of just VARCHAR? It is dynamic anyway. UPD: I'm puzzled specifically by the fact that it is mandatory (e.g. in MySQL). ...

can't find the type 'bigint' in Sybase ASE 12.5.4

Hi is bigint supported in Sybase ASE 12.5.4 ? if not is there any equalent to bigint in Sybase ASE 12.5.4 ? ...