Solved

Query Syntax With LIKE

Posted on 2014-09-20
4
154 Views
Last Modified: 2014-09-20
I have a variation on a question I asked earlier .  How do I use LIKE in the following query and then in creating the variables?
Line 7 and Line 20;

 	$check_alt  = 	"SELECT meta_value, meta_key
					FROM wp_woocommerce_order_itemmeta
					WHERE (meta_key = 'Bicycle Info - Primary Operator First Name'
					OR meta_key = 'Bicycle Info - Primary Operator Last Name'
					OR meta_key = 'Bicycle Info - Bicycle Serial Number'
					OR meta_key = '_line_total'
					OR meta_key LIKE 'Custom Price - Bicycle Liability %')
					AND order_item_id = :order_id ";
 	
		$checking_alt = $pdo->prepare($check_alt);		
		$checking_alt->execute(array(':order_id' => $order_id)) or die(print_r($checking_alt -> errorInfo()));
		$res_alt = $checking_alt->fetchAll();	
				
				if ($res_alt) {
					
					foreach ($res_alt as $rows)  {
						if($rows->meta_key == "_line_total") { 
							$total = $rows->meta_value;
						}
						elseif($rows->meta_key == 'Custom Price - Bicycle Liability')	{
							$total_liabil = $rows->meta_value;
						}			
						} 						           
					}		
				}	
			}

Open in new window

0
Comment
Question by:rgranlund
  • 2
4 Comments
 
LVL 82

Assisted Solution

by:Dave Baldwin
Dave Baldwin earned 150 total points
ID: 40334664
0
 
LVL 7

Author Comment

by:rgranlund
ID: 40334683
@dave, but it does not address how I write line 20  ???
0
 
LVL 58

Accepted Solution

by:
Gary earned 350 total points
ID: 40334690
if(strpos($rows->meta_key,"string-to-find") !== FALSE){
...
}

Open in new window

0
 
LVL 7

Author Comment

by:rgranlund
ID: 40334705
Thanks!
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

PL/SQL can be a very powerful tool for working directly with database tables. Being able to loop will allow you to perform more complex operations, but can be a little tricky to write correctly. This article will provide examples of basic loops alon…
This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now