[PHP-DB] Re: mysql_query

2009-08-10 Thread David Robley
Ron Piggott wrote:

 I have the syntax
 
 mysql_query(INSERT INTO ););
 
 If this is successful I want to do update a column in one of my tables
 
 $query = UPDATE ... ;
 mysql_query($query);
 
 How do I test if the INSERT INTO mysql_query, in order to trigger the
 UPDATE?
 
 Ron

You could check the mysql section of the documentation, where you will find
http://php.net/manual/en/function.mysql-affected-rows.php which will tell
you how many rows were affected by your INSERT. Alternatively, if you are
using Innodb tables, you could look at using transactions.


Cheers
-- 
David Robley

Those who can't write, write help files.
Today is Boomtime, the 3rd day of Bureaucracy in the YOLD 3175. 


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] mysql_query

2009-08-10 Thread Phpster





On Aug 10, 2009, at 4:15 AM, Ron Piggott  
ron@actsministries.org wrote:



I have the syntax

mysql_query(INSERT INTO ););

If this is successful I want to do update a column in one of my tables

$query = UPDATE ... ;
mysql_query($query);

How do I test if the INSERT INTO mysql_query, in order to trigger  
the UPDATE?


Ron


You could use the REPLACE syntax in mysql

http://dev.mysql.com/doc/refman/5.0/en/replace.html

Bastien

Sent from my iPod

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] adding a simple WHERE clause to this MySQL query causes the result to contain 0 rows?!

2009-08-10 Thread John Butler

If you're using windows, it's very easy.

http://www.apachefriends.org/en/index.html

It has a webserver (apache), mysql, phpmyadmin + a bunch of other  
stuff included in the one download. One click installer .. voila.


I'm on mac here where I develop.  I see they say the mac version is in  
first steps of development; use at your own risk.


But anyway maybe I am closer than that to start with.  I do have these  
running already (just have so little fluency in actually tweaking/ 
playing with them from the admin perspective) -

MySQL
PHP
Apache

So I gather I just need to know what is this, and where to install/ 
learn about it, and why-

phpMyAdmin (3.2.0.1)


John Butler (Govinda)
govinda.webdnat...@gmail.com





Re: [PHP-DB] adding a simple WHERE clause to this MySQL query causes the result to contain 0 rows?!

2009-08-10 Thread sono-io


On Aug 10, 2009, at 7:07 AM, John Butler wrote:


If you're using windows, it's very easy.

http://www.apachefriends.org/en/index.html

It has a webserver (apache), mysql, phpmyadmin + a bunch of other  
stuff included in the one download. One click installer .. voila.


I'm on mac here where I develop.  I see they say the mac version is  
in first steps of development; use at your own risk.


Since you're on a Mac, check out MAMP:

http://www.mamp.info/en/index.html

They have a free version and a Pro version.

Frank

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] Mysql multiple queries Vs. Query in multi-dimensional array

2009-08-10 Thread Drew Stokes

Hello all,
I have an enterprise application that needs to be optimized/re- 
engineered.  In the process of re-designing the framework, i stumbled  
across the idea of storing large mysql result sets in multi- 
dimensional arrays for easy/quick reference.


Basically, my application polls the database looking for 1 of up to 3  
documents for each day in the reporting period (1 to 4 weeks) for  
multiple clients, and follows a complex hierarchy based on the  
document and related information returned.  One of the areas i imagine  
i am losing resources is in the queries sent to the database where no  
result is returned.


My idea involves grabbing all of each document within the reporting  
period, and storing each type in its own multi-dimensional array with  
all other documents of the same type.  Then, throughout the report, i  
would check array keys for results instead of querying the database.   
It sounds like a sensible solution for taking some of the 2+  
queries of each report, but i'm not sure if the gains would be offset  
by the demands on RAM due to the large arrays.


Drew Stokes: Web Development at MPCS
contact | d...@mpcompliance.com | 818.792.4135
The information contained in this email message and its attachments is  
intended only for the private and confidential use of the recipient(s)  
named above, unless the sender expressly agrees otherwise. If the  
reader of this message is not the intended recipient and/or you have  
received this email in error, you must take no action based on the  
information in this email and you are hereby notified that any  
dissemination, misuse, copying, or disclosure of this communication is  
strictly prohibited. If you have received this communication in error,  
please notify us immediately by email and delete the original message.




Re: [PHP-DB] Mysql multiple queries Vs. Query in multi-dimensional array

2009-08-10 Thread Chris

Drew Stokes wrote:

Hello all,
I have an enterprise application that needs to be 
optimized/re-engineered.  In the process of re-designing the framework, 
i stumbled across the idea of storing large mysql result sets in 
multi-dimensional arrays for easy/quick reference.


Basically, my application polls the database looking for 1 of up to 3 
documents for each day in the reporting period (1 to 4 weeks) for 
multiple clients, and follows a complex hierarchy based on the document 
and related information returned.  One of the areas i imagine i am 
losing resources is in the queries sent to the database where no result 
is returned.


My idea involves grabbing all of each document within the reporting 
period, and storing each type in its own multi-dimensional array with 
all other documents of the same type.  Then, throughout the report, i 
would check array keys for results instead of querying the database.  It 
sounds like a sensible solution for taking some of the 2+ queries of 
each report, but i'm not sure if the gains would be offset by the 
demands on RAM due to the large arrays.


I can't see any report doing that number of queries (unless each query 
is just selecting a different column in the same table *maybe*), so 
looking at reducing that number is a good idea.


The arrays may work - but it depends. Are you fetching the same thing 
from the db each time or are you only using each piece of information once?


eg

$title = select title from table where id='x';
...
$title = select title from table where id='x';

If you are, then using an array of some sort would work nicely.

If you're doing the above for each entry in the db, maybe it would be 
quicker to retrieve everything and process in php.


$all_titles = select title from table;

It really depends on what the report is doing, what you're fetching from 
the database (and how) - so doing a new report using your new ideas 
(even with hardcoded values) is about the only way to find out for sure 
which is going to be better.


--
Postgresql  php tutorials
http://www.designmagick.com/


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php