[Phpwm] How to insert record into a database?

Ray Masa raymasa at hotmail.com
Fri Apr 21 19:29:08 BST 2006


Hi all,

Revisiting my previous issue with the database, I have another question.  As 
we all agreed, the database schematic for this database (I have includes 
table structure at the end of the email) is a bit convoluted (and I am a 
tinker, not an expert).  I am trying to figure out how to run basic insert, 
update, delete queries on this database.:

So, for example if I want to insert a new record into a database, I would 
use:

INSERT into table (address) VALUES (‘123 main street’);

Right?

But the following structure has data not in the field (e.g. address), but 
rather in an attribute (is that the right jargon?) within the field 
(en_listingsdbelements).  So if I wanted to insert ‘123 main street’ into 
address, how would I do that?


mysql> describe en_listingsdbelements;
+--------------------------------+-------------+------+-----+---------+----------------+
| Field                          | Type        | Null | Key | Default | 
Extra          |
+--------------------------------+-------------+------+-----+---------+----------------+
| listingsdbelements_id          | int(11)     |      | PRI | NULL    | 
auto_increment |
| listingsdbelements_field_name  | varchar(80) |      | MUL |         |      
           |
| listingsdbelements_field_value | text        |      | MUL |         |      
           |
| listingsdb_id                  | int(11)     |      | MUL | 0       |      
           |
| userdb_id                      | int(11)     |      |     | 0       |      
           |
+--------------------------------+-------------+------+-----+---------+----------------+



mysql> select * from  en_listingsdbelements;
+-----------------------+-------------------------------+--------------------------------+---------------+-----------+
| listingsdbelements_id | listingsdbelements_field_name | 
listingsdbelements_field_value | listingsdb_id | userdb_id |
+-----------------------+-------------------------------+--------------------------------+---------------+-----------+
|                  1828 | mls                           |                    
             |            17 |         1 |
|                  1827 | status                        | Active             
             |            17 |         1 |
|                  1826 | prop_tax                      |                    
             |            17 |         1 |
|                  1825 | lot_size                      |                    
             |            17 |         1 |
|                  1824 | sq_feet                       |                    
             |            17 |         1 |
|                  1823 | year_built                    |                    
             |            17 |         1 |
|                  1822 | floors                        |                    
             |            17 |         1 |
|                  1821 | baths                         |                    
             |            17 |         1 |
|                  1820 | beds                          |                    
             |            17 |         1 |
|                  1819 | full_desc                     |                    
             |            17 |         1 |
|                  1818 | price                         |                    
             |            17 |         1 |
|                  1817 | neighborhood                  |                    
             |            17 |         1 |
|                  1816 | country                       |                    
             |            17 |         1 |
|                  1815 | zip                           | H3A 1Y1            
             |            17 |         1 |
|                  1814 | state                         | Quebec             
             |            17 |         1 |
|                  1813 | city                          | Montréal           
             |            17 |         1 |
|                  1812 | garage_size                   |                    
             |            17 |         1 |
|                  1811 | address                       | 3459 Rue McTavish  
             |            17 |         1 |
|                  1810 | or_owner                      | 1                  
             |            17 |         1 |
|                  1809 | mlsexport                     | no                 
             |            17 |         1 |
+-----------------------+-------------------------------+--------------------------------+---------------+-----------+


Thanks,

Ray





More information about the Phpwm mailing list