mysql

sum value from mysql in php

Hi, Anyone knows how to get sum of number? For example i have mysql column name package. Package 3 4 1 3 4 If package 3, the value should be usd 5, if package 4, value should be usd 10, if package 1, value should be usd 1 and so on. So the total value above should be => 5 + 10 + 1 + 5 + 10 = 31 So how do i get sum of it in php? i...

protecting adobe air apps

Hi, I am about to deliver an Adobe AIR app to a customer. But it's my first delivery of any sort, i.e. I have no experience whatsoever with licensing etc. Users of this app may or may not be online, so can't count on that. In fact it's 99% sure that they will be offline. Nor do I expect them to very tech-savvy, who will spend enough t...

var for a class in PHP

Hello. I am using a PHP class for login purposes. The MySQL database that the login process checks for the user is defined like this: class flexibleAccess{ var $dbName = 'mydatabase'; However, as I install the application for different people, this $dbName needs constant changes. I have decided to make a config file where I kee...

How to create virtual column using MySQL SELECT ?

Hi, If I do SELECT a AS b and b is not a column in the table, would query create the "virtual" column? in fact, I need to incorporate some virtual column into the query and process some information into the query so I can use it with each item later on. ...

Can I change the packet size DBD::mysql uses?

I am running into the DBD::mysql::st execute failed: Got a packet bigger than 'max_allowed_packet' bytes error when trying to make a large insert using Perl & MySQL. I know that increasing the max_allowed_packet setting in my.cnf could fix this, but is it possible to tell DBI (or DBD::mysql, since my app really only needs to work wi...

Does adding 'LIMIT 1' to MySQL queries make them faster when you know there will only be 1 result?

When I add LIMIT 1 to a MySQL query, does it stop the search after it finds 1 result (thus making it faster) or does it still fetch all of the results and truncate at the end? ...

How to make a query to a table generated by a select?

As an example: SELECT name, address, phone FROM USER; Generates the table name | address | phone ... | ... | ... How can i use this table generated to make another query to it? For example: SELECT count(address) FROM (SELECT name, address, phone, from user); I know it's not the best example, but is there any way to do th...

Ajax: Partial refresh of a parent page (update a div) from "lightbox" window

Is there a way to update information in a div of a parent page from a pop-up/"lightbox" window. I would like to create a pop up window that contains a form that updates a database (currently i am using php/mysql with prototype). In other words... I would like a user to be able to use a form in a popup window to update the database, and...

Oracle to MySQL syntax question

Can someone show me the MySQL equivalent of the following statement (which works in Oracle 10g)? INSERT INTO VOUCHER (VOUCHER_NUMBER, BOOK_ID, DENOMINATION) SELECT a.a1, b.ID, b.DENOMINATION FROM (SELECT rownum a1 FROM dual CONNECT BY rownum <= 10000000) a, BOOK b where a.a1 between b.START_NUMBER and b.START_NUMBER+b.UNITS-1; Basica...

Is it possible to take a value from a row in one table in my MySQL database and insert into another table in the same database?

So say I have a products table with a list of products, and one of the fields is price. This table also has an id field. When someone makes a purchase I insert a row into another table called purchases. This table also has a field called price and a productid field that maps to the products table id field. I want to know if I can get the...

MySQL Syntax error message "Operand should contain 1 column(s)"

I tried running the following statement: INSERT INTO VOUCHER (VOUCHER_NUMBER, BOOK_ID, DENOMINATION) SELECT (a.number, b.ID, b.DENOMINATION) FROM temp_cheques a, BOOK b WHERE a.number BETWEEN b.START_NUMBER AND b.START_NUMBER+b.UNITS-1; which, as I understand it, should insert into VOUCHER each record from temp_cheques with the ID an...

Drop MySQL databases matching some wildcard?

Im runing mySQL in a server where i need to drop tons of databases (after some testing with the server). All databases that i need to drop have the same prefix "Whatever_". After the prefix, the names are random. So you have your Whatever_something, Whatever_232, Whatever_blabla, .... , Whatever_imthelast. I will be doing this job quit...

Syncronize two databases schema in MySQL

I was looking for a portable script or command line program that can syncronize two MySQL databases schema. I am not looking for a GUI based solution because that can't be automated or run with the buid/deployment tool. Basically what it should do is scan database1 and database2. Check the schema difference (tables and indexes) and prop...

Understanding input escaping in PHP

Hi, One thing that's always confused me is input escaping and whether or not you're protected from attacks like SQL injection. Say I have a form which sends data using HTTP POST to a PHP file. I type the following in an input field and submit the form: "Hello", said Jimmy O'Toole. If you print/echo the input on the PHP page that rec...

Changing tables from MyISAM to InnoDB make the system slow

Hi I am using Mysql 5.0.x I have just changed a lot of the tables from MyISAM to InnoDB With the MyISAM tables it took about 1 minute to install our database With the InnoDB it takes about 15 minute to install the same database Why does the InnoDB take so long? What can I do to speed things up? The Database install does the follow...

Should I COUNT(*) or not?

I know it's generally a bad idea to do queries like this: SELECT * FROM `group_relations` But when I just want the count, should I go for this query since that allows the table to change but still yields the same results. SELECT COUNT(*) FROM `group_relations` Or the more specfic SELECT COUNT(`group_id`) FROM `group_relations` I...

Symfony Propel criteria

Hi, Is there any possible way to convert the MySQL object into criteria object? I tried this query "select p.disrepid, p.subject, p.body, c.disrepid as disrepid1, c.subject as subject1, c.body as body1 from discusreply as p, discusreply as c where p.distopid='.$this->id.' and (c.disrepid = p.parentid or c.parentid = p.distopid) order by...

PHP MySql Where Field = <4 Words

I need to use a query which will pull data from a field when it is less then 4 words, is this possible and if so could you give some pointers? I suppose if not possible it could cycle through the results until it found one which was 3 words and then end the while statement when it has found one. ...

How do I update a change using SubSonic and MySQL

I was trying to TDD using SubSonic 2.1, MySQL and C# and when I got to testing updating an existing record using the code below, public void Test2() { User.Insert("jmarcus1", "jmarcus1", "jackass", "marcus", 3, false); User users = new User(); int ulevel = 1; User.Update(2, "jmarcus1", "jmarcus1", "jackass", "marcus", ul...

How can I find out how many rows a MySQL query returns in Java?

How can I find out how many rows a MySQL query returns in Java? ...