[PHP] Compare data between 2 array

2006-06-18 Thread weetat

Hi all,

  I would like to say good job to this newsgroup , they are the best.

  Ok. My dilemma is that i have to compare values between 2 table which 
are exactly the same structure and fields.

  Below is rough example .

   The table are tbl_chassis and tbl_chassis_temp. Below are the fields.

   `id` int(11) NOT NULL auto_increment,
  `serial_no` varchar(100) NOT NULL default '',
  `host_name` varchar(100) NOT NULL default '',
  `chasis_model` varchar(100) NOT NULL default '',
  `chasis_flash_size` varchar(100) NOT NULL default '',
  `chasis_dram_size` varchar(100) NOT NULL default '',
  `chasis_sw_version` varchar(100) NOT NULL default '',
  `chasis_eos` date NOT NULL default '-00-00',
  `chasis_eol` date NOT NULL default '-00-00',
  `chasis_user_field_1` varchar(100) NOT NULL default '',
  `chasis_user_field_2` varchar(100) NOT NULL default '',
  `chasis_user_field_3` varchar(100) NOT NULL default '',
   `status` varchar(100) NOT NULL default '',

What i need to figure out are when the records are deleted , updated and 
insert ,i need to update status in tbl_chassis table. What i am plan to 
do is to select query in the tbl_chassis_temp table and compare the 
value from each records to the records in the tbl_chassis table.Any 
others ways to do it?


There are about 1000 records in each table.
What is the better alternative to do this ? Thanks

 - weetat

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



Re: [PHP] Compare data between 2 array

2006-06-18 Thread Chris

weetat wrote:

Hi all,

  I would like to say good job to this newsgroup , they are the best.

  Ok. My dilemma is that i have to compare values between 2 table which 
are exactly the same structure and fields.

  Below is rough example .

   The table are tbl_chassis and tbl_chassis_temp. Below are the fields.

   `id` int(11) NOT NULL auto_increment,
  `serial_no` varchar(100) NOT NULL default '',
  `host_name` varchar(100) NOT NULL default '',
  `chasis_model` varchar(100) NOT NULL default '',
  `chasis_flash_size` varchar(100) NOT NULL default '',
  `chasis_dram_size` varchar(100) NOT NULL default '',
  `chasis_sw_version` varchar(100) NOT NULL default '',
  `chasis_eos` date NOT NULL default '-00-00',
  `chasis_eol` date NOT NULL default '-00-00',
  `chasis_user_field_1` varchar(100) NOT NULL default '',
  `chasis_user_field_2` varchar(100) NOT NULL default '',
  `chasis_user_field_3` varchar(100) NOT NULL default '',
   `status` varchar(100) NOT NULL default '',

What i need to figure out are when the records are deleted , updated and 
insert ,i need to update status in tbl_chassis table. What i am plan to 
do is to select query in the tbl_chassis_temp table and compare the 
value from each records to the records in the tbl_chassis table.Any 
others ways to do it?


If you're changing the status, why not do it in both tables at the same 
time?


$query = update table1 set status=newstatus where ...;
mysql_query($query);

$query = update table2 set status=newstatus where ...;
mysql_query($query);


Another option is to change to use the INNODB engine in mysql and use 
foreign keys (note they only work properly with InnoDB tables, MyISAM 
tables don't have this capability).


See

http://dev.mysql.com/doc/refman/5.1/en/innodb.html
http://dev.mysql.com/doc/refman/5.1/en/example-foreign-keys.html
http://dev.mysql.com/doc/refman/5.1/en/ansi-diff-foreign-keys.html

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

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