[PHP-DB] mysql lock

2003-06-27 Thread anders thoresson
Hi,

I've never used a lock on a MySQL table so far, but need one now. Two 
questions:

1. Do I set the lock by a normal query, but in the form of LOCK TABLE 
tablename WRITE, instead of SELECT * FROM tablename WHERE x = 1?

2. Can I set the lock in one query, then perform multiple other queries on 
the table, in between which I do some PHP work, and then release the lock 
several queries and lines of PHP code later?

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


Re: [PHP-DB] generating sequence without AUTO_INCREMENT

2003-06-27 Thread Lester Caine
Doing what I wanted to do took six hours and 120 lines of code, all in 
all, but I learnt a good deal on the way. ;-)
At times, manual intervention can be a lifesaver.
You have already said that you have to 'ring fence' bank 
holidays, and weekends, so someone has to check or enter the 
bank holidays.
So I would provide two 'fill' functions that populates an 
issue number table, and will either fill the week if no bank 
holidays, or fill each selected day when there is a bank 
holiday in the week.
This can then be done monthly or yearly as the look ahead 
time requires.
Or am I missing something - I've only ever used 
Interbase/Firebird, and never had a problem with this sort 
of ident.

--
Lester Caine
-
L.S.Caine Electronic Services
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP-DB] error checking question

2003-06-27 Thread Ford, Mike [LSS]
 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
 Sent: 26 June 2003 20:22
 
 What I would like to do is somehow have a redundant error 
 check on the server
 side and then display an error message above the form on the 
 main page should
 fields be left blank or forbidden characters entered. Since I 
 have access to the
 $_POST['variables'] on the form processing page, I've already 
 written some code
 to detect the presence of error characters, etc...and no 
 query is performed if
 there is an error.  But how do I pass a flag variable back 
 to the main page to
 echo an appropriate message above the form?

One simple way:

   header(Location: http:/your.server.name/path/to/main_page.php?err=$errcode);
   exit();

And then emit an error in main_page.php if $_GET['err'] is set.

If you're using sessions, another way would be to set an error variable in the session.

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 


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



RE: [PHP-DB] latest version of php only cgi?

2003-06-27 Thread Ford, Mike [LSS]
 -Original Message-
 From: Doug Finch [mailto:[EMAIL PROTECTED]
 Sent: 26 June 2003 21:12
 
 Is the newest version of php 4 only available as a cgi-based program?
 DF

No.

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



[PHP-DB] Re: php-db Digest 25 Jun 2003 15:10:42 -0000 Issue 1899

2003-06-27 Thread JeRRy
From: Jason Wong [EMAIL PROTECTED] 
To: [EMAIL PROTECTED] 
Date: Wed, 25 Jun 2003 04:03:53 +0800 
Subject: Re: [PHP-DB] md5 question! 



Plain Text Attachment [ Save to my Yahoo! Briefcase  |
 Download File ]  

On Tuesday 24 June 2003 22:36, Peter Beckman wrote:
 Most sites save/allow an 8 character password. 
Allowing 
alphanumerics and
 underscore, period and pound (_, ., #), that is
39^8, or 
5,352,009,260,481
 or about 5 trillion possible passwords.  If you
allow more than 8
 characters, that number increases.

If you're using md5 then there is no inherent
restriction on what 
characters 
and number of characters that can be used in the
password. The 
limitations 
are in the user, they'll probably use their phone
number, DOB, dog's 
name -- 
anything that's easy to remember ;-)

Hi,

Okay with the followup above is there a way to handle
a database table that will only allow certain
characters for a password?  (e.g. Only letters and
numbers and not _';:)(*^%$# etc...)  

I guess a easy managment way to do it is either via
the PHP code or via JavaScript.  Maybe more
professional would be in the PHP code.  Maybe the 'if'
statement would be ideal?  Any suggestions?

Also while on php talk how do I make a java popup
message appear in a PHP code?  Is there a way to do
this, alert?  There are many ways to do it im
Javascript but was wondering if PHP had a way to do it
in the PHP code itself.  (hidden away if possible)

Jerry



http://mobile.yahoo.com.au - Yahoo! Mobile
- Check  compose your email via SMS on your Telstra or Vodafone mobile.

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



RE: [PHP-DB] Splitting Product Catalogue Over Multiple Pages?

2003-06-27 Thread Gary . Every
If you're trying to do paging, it's quite simple (there are tons of examples
out there, search google for paging php)

$sql = select count(*) from table_name

$number_of_records = mysql_query($sql);
$pointer=0;
$recs_per_page=20;

if($number_of_records  $recs_per_page) {
// do a limit and keep the pointer
$sql = select * from other_table limit $pointer,$recs_per_page;

$pointer += $recs_per_page;


This isn't complete by any means but the point should be clear. You limit
the query by LIMIT starting_point,number_of_records_to_return at the end
of the sql statement.

Don't worry about the values in the column, just the amount of records you
want to return



Gary Every
Sr. UNIX Administrator
Ingram Entertainment
(615) 287-4876
Pay It Forward
mailto:[EMAIL PROTECTED]
http://accessingram.com


 -Original Message-
 From: Boa Constructor [mailto:[EMAIL PROTECTED]
 Sent: Thursday, June 26, 2003 10:25 PM
 To: [EMAIL PROTECTED]
 Subject: [PHP-DB] Splitting Product Catalogue Over Multiple Pages?
 
 
 Greetings all, I'm not sure if this has been discussed 
 recently, I've read
 bits and pieces and I can't remember where I read everything 
 so if it has
 been brought up recently - sorry.
 
 If I do an SQL (MySQL) query on the first example to get the 
 min and max IDs
 then I will get 1 and 6 respectively.  I will then be able to 
 loop from 1 to
 6 and return all 6 products from the database.  If however I 
 wanted to split
 this in to two pages with 3 items in each page then using the 
 first example
 below I could grab the min ID and add 2 to it to make 3.  I 
 could not do
 this using the second example because if I grab the min ID I 
 would get 3, if
 I add 2 to it then I would get 5.  5 does not exit in this 
 table so that
 wouldn't work.  How in example 2 would I be able to split 
 this over two
 pages?
 
 //example 1
 
 ID   Product_Name
 1  Hoover
 2  Kettle
 3  Fridge
 4  Cooker
 5  Food Mixer
 6  TV
 
 //example 2
 
 ID   Product_Name
 3 Fridge
 4 Cooker
 7 Microwave Oven
 8 Freezer
 9 DVD Player
 10   Computer
 
 
 Any ideas?
 
 Anything is much appreciated.
 
 Graeme :)
 
 
 -- 
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 


Re: [PHP-DB] Splitting Product Catalogue Over Multiple Pages?

2003-06-27 Thread Boa Constructor
Gary, thanks for your reply, I think I'll need 2 have a think about this.  I
didn't totally understand:

You limit
 the query by LIMIT starting_point,number_of_records_to_return at the end
 of the sql statement.

I've never used LIMIT before, could you explain this a bit more or point me
to some info?


Cheers,

Graeme :)


- Original Message -
From: [EMAIL PROTECTED]
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Sent: Friday, June 27, 2003 2:39 PM
Subject: RE: [PHP-DB] Splitting Product Catalogue Over Multiple Pages?


 If you're trying to do paging, it's quite simple (there are tons of
examples
 out there, search google for paging php)

 $sql = select count(*) from table_name

 $number_of_records = mysql_query($sql);
 $pointer=0;
 $recs_per_page=20;

 if($number_of_records  $recs_per_page) {
 // do a limit and keep the pointer
 $sql = select * from other_table limit $pointer,$recs_per_page;

 $pointer += $recs_per_page;


 This isn't complete by any means but the point should be clear. You limit
 the query by LIMIT starting_point,number_of_records_to_return at the end
 of the sql statement.

 Don't worry about the values in the column, just the amount of records you
 want to return



 Gary Every
 Sr. UNIX Administrator
 Ingram Entertainment
 (615) 287-4876
 Pay It Forward
 mailto:[EMAIL PROTECTED]
 http://accessingram.com


  -Original Message-
  From: Boa Constructor [mailto:[EMAIL PROTECTED]
  Sent: Thursday, June 26, 2003 10:25 PM
  To: [EMAIL PROTECTED]
  Subject: [PHP-DB] Splitting Product Catalogue Over Multiple Pages?
 
 
  Greetings all, I'm not sure if this has been discussed
  recently, I've read
  bits and pieces and I can't remember where I read everything
  so if it has
  been brought up recently - sorry.
 
  If I do an SQL (MySQL) query on the first example to get the
  min and max IDs
  then I will get 1 and 6 respectively.  I will then be able to
  loop from 1 to
  6 and return all 6 products from the database.  If however I
  wanted to split
  this in to two pages with 3 items in each page then using the
  first example
  below I could grab the min ID and add 2 to it to make 3.  I
  could not do
  this using the second example because if I grab the min ID I
  would get 3, if
  I add 2 to it then I would get 5.  5 does not exit in this
  table so that
  wouldn't work.  How in example 2 would I be able to split
  this over two
  pages?
 
  //example 1
 
  ID   Product_Name
  1  Hoover
  2  Kettle
  3  Fridge
  4  Cooker
  5  Food Mixer
  6  TV
 
  //example 2
 
  ID   Product_Name
  3 Fridge
  4 Cooker
  7 Microwave Oven
  8 Freezer
  9 DVD Player
  10   Computer
 
 
  Any ideas?
 
  Anything is much appreciated.
 
  Graeme :)
 
 
  --
  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



[PHP-DB] re:[PHP-DB] Splitting Product catalog

2003-06-27 Thread Michael Lewis
Graeme,

Use a select string as in,

$sel=select * from product where price100 order by price LIMIT 0,100;

This would result in the query only returning the first 100 records. If you
want to page through them (back and next links). You would have to save the
current start point and the length would be the number of records you want
to display. Take the following example (please) which selected records in
groups of tens:

session_start();
$start=$_SESSION['start'];
sel=select count(*) from product;
$res=mysql_query($sel) or die(mysql_error());
$r=mysql_fetch_array($res);
$totalmsg=$r[0];
if ($start$totalmsg) {
$start=0;
$_SESSION['start']=0;
}
$res=mysql_query($sel) or die(mysql_error);
$numtoprocess=10;
$numselected=mysql_num_rows($res);
if ($numselected$numtoprocess) {
$numtoprocess=$numselected;
}
$sel=select * from product limit $start,$numtoprocess;
for ($i=0;$i$numtoprocess;$i++) {
process the record here
}
$start+=$i;
$_SESSION['start']=$start;

yada, yada, yada (put your back and next buttons here)

The above code is stripped of most error checking etc., but it should give
you a framework to get started.

Michael Lewis



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



RE: [PHP-DB] Splitting Product Catalogue Over Multiple Pages?

2003-06-27 Thread Gary . Every
LIMIT 0,10 will return the first ten records of a result set. To make more
sense, you should do an ORDER BY of some field to get the info sorted
correctly. 
LIMIT takes 1 or two arguments
If there is only one argument, say 10, it will return the first ten records.
If there are two arguments, LIMIT 20,10 it will return 10 records starting
at record 20.

More info at
http://www.mysql.com/doc/en/SELECT.html
Search for limit on that page.


Gary Every
Sr. UNIX Administrator
Ingram Entertainment
(615) 287-4876
Pay It Forward
mailto:[EMAIL PROTECTED]
http://accessingram.com


 -Original Message-
 From: Boa Constructor [mailto:[EMAIL PROTECTED]
 Sent: Friday, June 27, 2003 9:20 AM
 To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
 Subject: Re: [PHP-DB] Splitting Product Catalogue Over Multiple Pages?
 
 
 Gary, thanks for your reply, I think I'll need 2 have a think 
 about this.  I
 didn't totally understand:
 
 You limit
  the query by LIMIT 
 starting_point,number_of_records_to_return at the end
  of the sql statement.
 
 I've never used LIMIT before, could you explain this a bit 
 more or point me
 to some info?
 
 
 Cheers,
 
 Graeme :)
 
 
 - Original Message -
 From: [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
 Sent: Friday, June 27, 2003 2:39 PM
 Subject: RE: [PHP-DB] Splitting Product Catalogue Over Multiple Pages?
 
 
  If you're trying to do paging, it's quite simple (there are tons of
 examples
  out there, search google for paging php)
 
  $sql = select count(*) from table_name
 
  $number_of_records = mysql_query($sql);
  $pointer=0;
  $recs_per_page=20;
 
  if($number_of_records  $recs_per_page) {
  // do a limit and keep the pointer
  $sql = select * from other_table limit $pointer,$recs_per_page;
 
  $pointer += $recs_per_page;
 
 
  This isn't complete by any means but the point should be 
 clear. You limit
  the query by LIMIT 
 starting_point,number_of_records_to_return at the end
  of the sql statement.
 
  Don't worry about the values in the column, just the amount 
 of records you
  want to return
 
 
 
  Gary Every
  Sr. UNIX Administrator
  Ingram Entertainment
  (615) 287-4876
  Pay It Forward
  mailto:[EMAIL PROTECTED]
  http://accessingram.com
 
 
   -Original Message-
   From: Boa Constructor [mailto:[EMAIL PROTECTED]
   Sent: Thursday, June 26, 2003 10:25 PM
   To: [EMAIL PROTECTED]
   Subject: [PHP-DB] Splitting Product Catalogue Over Multiple Pages?
  
  
   Greetings all, I'm not sure if this has been discussed
   recently, I've read
   bits and pieces and I can't remember where I read everything
   so if it has
   been brought up recently - sorry.
  
   If I do an SQL (MySQL) query on the first example to get the
   min and max IDs
   then I will get 1 and 6 respectively.  I will then be able to
   loop from 1 to
   6 and return all 6 products from the database.  If however I
   wanted to split
   this in to two pages with 3 items in each page then using the
   first example
   below I could grab the min ID and add 2 to it to make 3.  I
   could not do
   this using the second example because if I grab the min ID I
   would get 3, if
   I add 2 to it then I would get 5.  5 does not exit in this
   table so that
   wouldn't work.  How in example 2 would I be able to split
   this over two
   pages?
  
   //example 1
  
   ID   Product_Name
   1  Hoover
   2  Kettle
   3  Fridge
   4  Cooker
   5  Food Mixer
   6  TV
  
   //example 2
  
   ID   Product_Name
   3 Fridge
   4 Cooker
   7 Microwave Oven
   8 Freezer
   9 DVD Player
   10   Computer
  
  
   Any ideas?
  
   Anything is much appreciated.
  
   Graeme :)
  
  
   --
   PHP Database Mailing List (http://www.php.net/)
   To unsubscribe, visit: http://www.php.net/unsub.php
  
 
 


Re: [PHP-DB] re:[PHP-DB] Splitting Product catalog

2003-06-27 Thread Boa Constructor
Michael, thank you so much for that code.  I think I could maybe get this
working properly.  I've got 2 categories and 4 products in each and I want
to split them in to 2 pages, 2 products on each.  So obviously I will have 2
links at the bottom page 1 2.. etc   when I click the link 2 I will
need 2 tell the database to look up the 3rd and 4th record.  So would it be
possible to pass a parameter in the URL such as newpage=2 then multiply
it by 2 and use that as the maximum limit then take 1 away from that value
and use that as the minimum limit in the SQL query?

Basically:

2x2 = 4 (maximum limit)
4-1 = 3  (minimum limit)

Would this work?

Cheers,

Graeme :)

- Original Message -
From: Michael Lewis [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Friday, June 27, 2003 3:47 PM
Subject: [PHP-DB] re:[PHP-DB] Splitting Product catalog


 Graeme,

 Use a select string as in,

 $sel=select * from product where price100 order by price LIMIT
0,100;

 This would result in the query only returning the first 100 records. If
you
 want to page through them (back and next links). You would have to save
the
 current start point and the length would be the number of records you want
 to display. Take the following example (please) which selected records in
 groups of tens:

 session_start();
 $start=$_SESSION['start'];
 sel=select count(*) from product;
 $res=mysql_query($sel) or die(mysql_error());
 $r=mysql_fetch_array($res);
 $totalmsg=$r[0];
 if ($start$totalmsg) {
 $start=0;
 $_SESSION['start']=0;
 }
 $res=mysql_query($sel) or die(mysql_error);
 $numtoprocess=10;
 $numselected=mysql_num_rows($res);
 if ($numselected$numtoprocess) {
 $numtoprocess=$numselected;
 }
 $sel=select * from product limit $start,$numtoprocess;
 for ($i=0;$i$numtoprocess;$i++) {
 process the record here
 }
 $start+=$i;
 $_SESSION['start']=$start;

 yada, yada, yada (put your back and next buttons here)

 The above code is stripped of most error checking etc., but it should give
 you a framework to get started.

 Michael Lewis



 --
 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



Re: [PHP-DB] Splitting Product Catalogue Over Multiple Pages?

2003-06-27 Thread Boa Constructor
RE: [PHP-DB] Splitting Product Catalogue Over Multiple Pages?Ahhh rite, I think I get 
this, I've just posted another question but I think I it will work if I do it the way 
I suggest in my last post.  If not please let me know.


Thank you both Gary and Michael!

Cheers,

Graeme :)
  - Original Message - 
  From: [EMAIL PROTECTED] 
  To: [EMAIL PROTECTED] ; [EMAIL PROTECTED] ; [EMAIL PROTECTED] 
  Sent: Friday, June 27, 2003 3:44 PM
  Subject: RE: [PHP-DB] Splitting Product Catalogue Over Multiple Pages?


  LIMIT 0,10 will return the first ten records of a result set. To make more sense, 
you should do an ORDER BY of some field to get the info sorted correctly. 

  LIMIT takes 1 or two arguments 
  If there is only one argument, say 10, it will return the first ten records. If 
there are two arguments, LIMIT 20,10 it will return 10 records starting at record 20.

  More info at 
  http://www.mysql.com/doc/en/SELECT.html 
  Search for limit on that page. 



  Gary Every 
  Sr. UNIX Administrator 
  Ingram Entertainment 
  (615) 287-4876 
  Pay It Forward 
  mailto:[EMAIL PROTECTED] 
  http://accessingram.com 



   -Original Message- 
   From: Boa Constructor [mailto:[EMAIL PROTECTED] 
   Sent: Friday, June 27, 2003 9:20 AM 
   To: [EMAIL PROTECTED]; [EMAIL PROTECTED] 
   Subject: Re: [PHP-DB] Splitting Product Catalogue Over Multiple Pages? 
   
   
   Gary, thanks for your reply, I think I'll need 2 have a think 
   about this.  I 
   didn't totally understand: 
   
   You limit 
the query by LIMIT 
   starting_point,number_of_records_to_return at the end 
of the sql statement. 
   
   I've never used LIMIT before, could you explain this a bit 
   more or point me 
   to some info? 
   
   
   Cheers, 
   
   Graeme :) 
   
   
   - Original Message - 
   From: [EMAIL PROTECTED] 
   To: [EMAIL PROTECTED]; [EMAIL PROTECTED] 
   Sent: Friday, June 27, 2003 2:39 PM 
   Subject: RE: [PHP-DB] Splitting Product Catalogue Over Multiple Pages? 
   
   
If you're trying to do paging, it's quite simple (there are tons of 
   examples 
out there, search google for paging php) 

$sql = select count(*) from table_name 

$number_of_records = mysql_query($sql); 
$pointer=0; 
$recs_per_page=20; 

if($number_of_records  $recs_per_page) { 
// do a limit and keep the pointer 
$sql = select * from other_table limit $pointer,$recs_per_page; 

$pointer += $recs_per_page; 


This isn't complete by any means but the point should be 
   clear. You limit 
the query by LIMIT 
   starting_point,number_of_records_to_return at the end 
of the sql statement. 

Don't worry about the values in the column, just the amount 
   of records you 
want to return 



Gary Every 
Sr. UNIX Administrator 
Ingram Entertainment 
(615) 287-4876 
Pay It Forward 
mailto:[EMAIL PROTECTED] 
http://accessingram.com 


 -Original Message- 
 From: Boa Constructor [mailto:[EMAIL PROTECTED] 
 Sent: Thursday, June 26, 2003 10:25 PM 
 To: [EMAIL PROTECTED] 
 Subject: [PHP-DB] Splitting Product Catalogue Over Multiple Pages? 
 
 
 Greetings all, I'm not sure if this has been discussed 
 recently, I've read 
 bits and pieces and I can't remember where I read everything 
 so if it has 
 been brought up recently - sorry. 
 
 If I do an SQL (MySQL) query on the first example to get the 
 min and max IDs 
 then I will get 1 and 6 respectively.  I will then be able to 
 loop from 1 to 
 6 and return all 6 products from the database.  If however I 
 wanted to split 
 this in to two pages with 3 items in each page then using the 
 first example 
 below I could grab the min ID and add 2 to it to make 3.  I 
 could not do 
 this using the second example because if I grab the min ID I 
 would get 3, if 
 I add 2 to it then I would get 5.  5 does not exit in this 
 table so that 
 wouldn't work.  How in example 2 would I be able to split 
 this over two 
 pages? 
 
 //example 1 
 
 ID   Product_Name 
 1  Hoover 
 2  Kettle 
 3  Fridge 
 4  Cooker 
 5  Food Mixer 
 6  TV 
 
 //example 2 
 
 ID   Product_Name 
 3 Fridge 
 4 Cooker 
 7 Microwave Oven 
 8 Freezer 
 9 DVD Player 
 10   Computer 
 
 
 Any ideas? 
 
 Anything is much appreciated. 
 
 Graeme :) 
 
 
 -- 
 PHP Database Mailing List (http://www.php.net/) 
 To unsubscribe, visit: http://www.php.net/unsub.php 
 

   


[PHP-DB] redirection checking

2003-06-27 Thread Doug Finch
I am compiling latest PHP4 and get a warning telling me that I am about
to compile without redirection checking.  Should I be concerned about
this?  If so, what flag should I use in the config to alleviate this?
DF




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



Re: [PHP-DB] Re: Efficiency question

2003-06-27 Thread Micah Stevens
Peter and Hugh,

The queries are already mostly optimized. I just was using that one as an 
example. I'll be going through them and tweaking them, but know that about 
the variable assignments helps for sure. 

Thanks!


On Thu June 26 2003 10:49 pm, Peter Beckman wrote:
 Since this is the PHP DB list, I can tell you this -- you would be better
 off performance-wise replacing the * in select * from and replacing it
 with a list of the columns (even if it is all of them) than you would
 putting all of that on one line.

 $r = rand(0,7)*-1;
 $s = abs($r);

 is as fast as (maybe a few CPU cycles, but when you're talking 2GHz
 processor, eh)

 $s = abs(rand(0,7)*-1);

 The second is probably more elegant, but then again, you still have to
 check to see what $data contains -- the DB might not have returned a row
 (for some unknown reason).

 Optimize DB calls before compacting variables.  I'm all about writing
 compact optimized code, but your DB calls and DB layout (indexes and
 queries mostly, but also table design) cost the most performance-wise and
 you're better off spending time getting them better.

 I highly recommend:
 http://www.mysql.com/documentation/mysql/bychapter/manual_MySQL_Optimisatio
n.html#Estimating_performance

 Peter

 On Thu, 26 Jun 2003, Hugh Bothwell wrote:
  Micah Stevens [EMAIL PROTECTED] wrote in message
  news:[EMAIL PROTECTED]
 
   $data = mysql_fetch_assoc(mysql_query(select * from some_table limit
 
  1));
 
   would be faster than:
  
   $pointer = mysql_query(select * from some_table limit 1);
   $data = mysql_fetch_assoc($pointer);
  
   but I'm not sure, php may optimize this. Anyone know the answer?
 
  It will be faster by one store and one fetch... the
  database query probably takes 1000 times as long.
  I don't think the difference is worth the time you'd
  take to change it.
 
  --
  Hugh Bothwell [EMAIL PROTECTED] Kingston ON Canada
  v3.1 GCS/E/AT d- s+: a- C+++ L+$ P+ E- W+++$ N++ K? w++ M PS+
  PE++ Y+ PGP+ t-- 5++ !X R+ tv b DI+++ D-(++) G+ e(++) h-- r- y+
 
 
 
 
  --
  PHP Database Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php

 ---
 Peter Beckman  Internet Guy
 [EMAIL PROTECTED] http://www.purplecow.com/
 ---


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



[PHP-DB] Altering a column in an existing table

2003-06-27 Thread Rick Dahl
I have a column (ID) that is currently not auto_incremental.  I need to change it so 
that it is auto_incremental.  There are already records in this column.  also, I need 
to change the field type from int(4) to int(8).

Rick


Re: [PHP-DB] Altering a column in an existing table

2003-06-27 Thread Leif K-Brooks
Rick Dahl wrote:

I have a column (ID) that is currently not auto_incremental.  I need to change it so that it is auto_incremental.  There are already records in this column.  also, I need to change the field type from int(4) to int(8).

Rick

 

1) This has nothing to do with PHP.
2) This will most likely require an ALTER query.
3) Read your DB's manual.
--
The above message is encrypted with double rot13 encoding.  Any unauthorized attempt 
to decrypt it will be prosecuted to the full extent of the law.


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