mysql

Generating XML based on condition in PHP

Is it possible to generate XML based on condition. I am getting the XML output from Database, but i want to display the nodes in such a manner based on the ID. If id of the elements are same, they should come under one node. ...

How to cast a 32-bit integer from unsigned to signed in MySQL or PHP?

Hello, I have a string in PHP (came from some data source), which represents a formatted unsigned 32-bit integer. I need to store it into a MySQL database as a signed 32-bit integer, so that later I can retrieve it from PHP and use it as a (possibly negative) signed integer constant (since PHP doesn't have unsigned integers). So, what ...

Update statement not working....

function add_new($father,$chName) // add new category { if($father = "1" ) { $result = mysql_query("INSERT into stinky_menu (title,nest_under) VALUES('".$chName."','1')"); } else { $result = mysql_query("UPDATE stinky_menu SET title = '$chName' nest_under = '$father'"); } } I am getting the value of f...

To run a .sql -file in MySQL

This question is based on this thread. I run unsuccessfully sudo mysql \. /users/cs/SO_db/posts.sql I get the error ERROR 1146 (42S02): Table 'personal.posts' doesn't exist MySQL's manual says A five-character SQLSTATE value ('42S02'). The values are specified by ANSI SQL and ODBC and are more standardized. Not all MySQ...

Linking tables when grouping

Hi can anyone help me with this I have this query I am developing select X.col1, X.col2, X.col3, X.col4 from table X join (select col3, min(col4) as mcol4 from table group by col3) as Y on X.col3=Y.col3 and X.col4=Y.mcol4 where X.col2='xxx'; Thanks to Draemon and this works great What I'd like to do if possible is to link X.col1 ...

Sum amount of overlapping datetime ranges in MySQL

I have a table of events, each with a StartTime and EndTime (as type DateTime) in a MySQL Table. I'm trying to output the sum of overlapping times and the number of events that overlapped. What is the most efficient / simple way to perform this query in MySQL? CREATE TABLE IF NOT EXISTS `events` ( `EventID` int(10) unsigned NOT NUL...

CRUD for mySQL and PHP

I have to make some database request with php on a mySQL database Question : What is the best (simpliest) framewok to get thing done right CRUD (create read update delete) I also have to populdate the database, what is a good tool to do that. The only one i know is sqlmyadmin, wich does not look good. An online tool will be great Your...

Linking two tables in a query....

I have two fields... one is category name and other is document title... When i click on submit... the document title should be saved in document table linking to the category name selected... which is in other table. A category can have n number of document titles... $result = mysql_query("UPDATE stinky_menu SET description = '$doc...

How should I store product and product image data for an online store?

I'm working on a storefront application in PHP with MySQL. I'm currently storing my data in 4 tables: one for product lines, one for specific products within those product lines, one for product images, and one which specifies which images are linked to which specific products. Each specific product belongs to one product line, each prod...

MySQL + PHP: How to do search and show summary rather than entire result

Hi, was wondering how to do a search result using PHP + MySQL but not show all the data in the result but only a SUMMARY (lets say limited to 200 characters). And the summary would exactly contain the keyword portion. So -100 characters+keyword+100 characters might be how it would be shown. Thanks! ...

Zend CLI not working

My app is working from the web side of things. I'd like to get the CLI working so that I can run unit tests and the such Here's what I have for a test script: $pthRoot = dirname(__FILE__); define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/..')); define('APPLICATION_ENV', 'development'); define('SERVER_ROLE', 'development'); s...

Sorting ActiveRecord models by sub-model attributes?

Lets assume I have a model Category which has_many Items. Now, I'd like to present a table of Categories sorted on various attributes of Items. For example, have the category with the highest priced item at the top. Or sort the categories based on their best rated item. Or sort the categories based on the most recent item (i.e., the cate...

Empty set returned from query

Any help is greatly appreciated. I have a table hospital: Nurse + Year + No.Patients A001 |2000 | 23 A001 |2001 | 30 A001 |2002 | 35 B001 |2000 | 12 B001 |2001 | 15 B001 |2002 | 45 C001 |2000 | 50 C002 |2001 | 59 C003 |2002 | 69 etc What I am trying to do is work out which nurse had the gr...

Quering Two tables... in MySQL

CREATE TABLE IF NOT EXISTS `document` ( `intId` int(11) NOT NULL auto_increment, `chDocumentTitle` varchar(32) default NULL, `dtLastUpdate` datetime default NULL, `chUser` varchar(32) default NULL, `chLink` varchar(256) default NULL, `Keyword` varchar(256) default NULL, `intParentid` int(11) NOT NULL, PRIMARY KEY (`intId...

some Hibernate Question

I have 2 question I wanna make Mysql table that have charset utf8 but I don't know where I shoud set the setting. (I just have a hibernate.cfg.XMl no any .xml file for hibernate) i dun want set mysql.ini file that default setting was UTF-8 I wanna put this setting in my hibernate. second Question: I have this table: CREATE TABLE `bui...

Where do I find the MysqlDumpSlow command ?

Hi I'm logging slow queries because we're having some performance issues and I have read about mysqldumpslow and thought that would be a good way to sort through the queries. At the command prompt I type mysqldumpslow and I get this: 'mysqldumpslow' is not recognized as an internal or external command, operable program or bat...

phpmyadmin "no data received to import" error, how to fix?

I use xampp on a pc atwork to host a database. I exported a backup ("bintra.sql") using phpmybackuppro. I use xampp on a mac at home, and when I try to import the sql file located on my desktop, I get this error. No data was received to import. Either no file name was submitted, or the file size exceeded the maximum size perm...

MySQL, select records with at least X characters matching

Hello, I am trying to accomplish the following. Let's say we have a table that contains these fields (ID, content) 1 | apple 2 | pineapple 3 | application 4 | nation now, I am looking for a function that will tell me all possible common matches. For example, if the argument is "3", the function will return all possible strings from...

Matching data

Any help here would be greatly appreciated. I have this table hospital Nurse | Ward | Doctor A001 | W2 | DR1 A001 | W2 | DR2 F002 | W2 | DR1 F005 | W2 | DR1 F005 | W2 | DR2 J003 | W4 | DR5 What I am trying to do is display what Nurse on Ward 2 works with Doctor 1 but not Doc...

Error Levels and Error on which line?

I have a PHP script vieworder.php that includes other scripts at the top. <?php include "../includes/config.php"; include "../includes/session.php"; include "../includes/functions.php"; //... ?> I get an error on this PHP script. It tells me this: Warning: mysql_num_rows(): supplied argument ... in vieworder.php on line 185 Do I n...