php - MySQL - Perform JOIN from serialized array? -



php - MySQL - Perform JOIN from serialized array? -

i creating simple cart script php , mysql, , having problem figuring out fastest , efficient way perform query.

i have table called carts , table called products. carts table has column called contents contains serialized array of item numbers. these items numbers correspond pid column of products.

what looking have query pull array of info , match contents of array corresponding rows in products can echo out of matching info product.

create table `carts` ( `cart_id` int(10) not null auto_increment, `session_id` varchar(50) null default null, `contents` longtext null, `first_name` varchar(50) null default null, `last_name` varchar(50) null default null, `address` varchar(100) null default null, `city` varchar(100) null default null, `state` varchar(100) null default null, `postal` varchar(20) null default null, `country` varchar(20) null default null, primary key (`cart_id`), unique index `session_id` (`session_id`) ) collate='utf8_general_ci' engine=myisam auto_increment=7; create table `products` ( `pid` int(4) not null auto_increment, `itemtitle` varchar(100) not null, `itemnumber` varchar(10) not null, `itemdescription` longtext not null, `imgarray` longtext not null, `visibility` tinyint(1) not null, `availability` tinyint(1) not null, `itemprice` decimal(8,2) not null, `accentcolor` varchar(11) not null, primary key (`pid`) ) collate='latin1_swedish_ci' engine=myisam auto_increment=143;

sample serialized array: a:6:{i:0;s:3:"115";i:2;s:2:"82";i:4;s:2:"79";i:5;s:2:"58";i:6;s:2:"38";i:7;s:2:"85";}

while may technically possible, should not seek join on serialized column. fastest way using bridge table between cart , products. shouldn't hard modify code work off of rows in bridge table instead of single serialized field.

php mysql arrays serialization join

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -