Re: [PHP-DB] mysqldump via php

2006-06-30 Thread Jeffrey

Thanks all for the help!

exec() seems the best option.

Jeffrey

Miguel Guirao wrote:


You could use exec() within PHP!

-Original Message-
From: Adrian Bruce [mailto:[EMAIL PROTECTED]
Sent: Jueves, 29 de Junio de 2006 06:31 a.m.
To: Jeffrey
Cc: PHP DB
Subject: Re: [PHP-DB] mysqldump via php


mysqldump is a .exe, and therefore it will not work within mysql_query();

You may be able to use  mysqldump from PHP using the system function

check out http://uk.php.net/system

Ade

Jeffrey wrote:

I would like to do a backup of an entire MySQL database via php. My 
thought was to use mysqldump, write the data to a file and save the 
file. However...


   $query=mysqldump $dbase;
   $result=mysql_query($query) or die(mysql_error());

...immediately results in an error in your SQL syntax near mysqldump 
[database name].


The reason I want to do a MySQL back up via php is that I have a web 
application in which the user can archive a project, which involves 
moving a lot data from one set of tables to another set of tables. The 
user can also delete a project, which removes lots of data from the DB 
altogether. Although there are lots of Are you sure you really want 
to do this? messages the user must click upon, I am sure I will 
eventually get a user telling me she accidentally archived/deleted 
stuff and can I help.


So, my thought was to do a incorporate a mysqldump in the 
archiving/delete page. That way there would be a snapshot of the 
pre-action db, making it easy to put things right.


Can you help with my query - or by suggesting an alternative solution?

Thanks,

Jeffrey






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



Re: [PHP-DB] LIMIT

2006-06-30 Thread Chris

If you're using MySQL then:

SELECT SQL_CALC_FOUND_ROWS * FROM aTable LIMIT 5
SELECT FOUND_ROWS()

It's in the mysql documentation under SELECT syntax I believe.

Chris

Dwight Altman wrote:

Is there a way to get the number of rows that would have been returned had
there not been a LIMIT clause in a SELECT statement?

For example, if
Query #1) SELECT * FROM aTable
would normally return 100 rows.  But
Query #2) SELECT * FROM aTable LIMIT 5
will return 5 rows.  Is there a way to find out that 100 rows would have
been returned if there was no LIMIT clause, by using only Query #2 and maybe
a PHP function on the $result?

Regards,
Dwight


  


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



RE: [PHP-DB] LIMIT

2006-06-30 Thread Dwight Altman
Thanks, but that's an additional query.

I was wondering if there may be a PHP function that can operate on the
$result or perhaps $link of the single query that uses a LIMIT clause and
have the information [count(*) had there not been a LIMIT clause
count_no_limit(*) maybe? even though there was a LIMIT clause].  Something
like mysql_info.

Regards,
Dwight
x2407

 -Original Message-
 From: Frank M. Kromann [mailto:[EMAIL PROTECTED]
 Sent: Thursday, June 29, 2006 5:46 PM
 To: Dwight Altman
 Cc: php-db@lists.php.net
 Subject: Re: [PHP-DB] LIMIT
 
 What about 'select count(*) from aTable'
 
 - Frank
 
  Is there a way to get the number of rows that would have been returned
 had
  there not been a LIMIT clause in a SELECT statement?
 
  For example, if
  Query #1) SELECT * FROM aTable
  would normally return 100 rows.  But
  Query #2) SELECT * FROM aTable LIMIT 5
  will return 5 rows.  Is there a way to find out that 100 rows would
 have
  been returned if there was no LIMIT clause, by using only Query #2 and
 maybe
  a PHP function on the $result?
 
  Regards,
  Dwight
 
 
  --
  PHP Database Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 


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