6 Replies - 387 Views - Last Post: 28 February 2019 - 09:39 AM

#1 DJPRiZM   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 20-February 19

pulling from MySQL

Posted 20 February 2019 - 04:59 PM

I am trying to Pull from MySQL but just can't get the string right to pull from the right field.

it is pulling from the wrong location. currently from (catalog_product_entity_media_gallery_value_video) and should be pulling the video from (catalog_product_entity_varchar) (attribute id 147) this gives the value for the correct not sure what is the correct code string.

$sql = "SELECT url FROM catalog_product_entity_media_gallery_value_video where value_id= ".$product_data['entity_id']." ";
		$video_url = $connection->fetchOne($sql);


I am trying this but has to have the 'attribute_id' of 174 to pull the correct 'value' and get the URL in the database.

$sql = "SELECT url FROM catalog_product_entity_varchar where value_id= ".$product_data['value']." ";
		$video_url = $connection->fetchOne($sql);



any thoughts on how to add the attribute_id of 174 in this string..?

Thanks PRiZM..

Attached image(s)

  • Attached Image

This post has been edited by andrewsw: 21 February 2019 - 01:42 AM
Reason for edit:: fixed botched [code][/code] tags


Is This A Good Question/Topic? 0
  • +

Replies To: pulling from MySQL

#2 andrewsw   User is offline

  • never lube your breaks
  • member icon

Reputation: 6823
  • View blog
  • Posts: 28,274
  • Joined: 12-December 12

Re: pulling from MySQL

Posted 21 February 2019 - 01:41 AM

Your question is unclear. If you want to filter on the attribute_id field then change value_id to attribute_id in the statement.

Use parameterized queries, do not directly inject values into a SQL statement.
Was This Post Helpful? 0
  • +
  • -

#3 ajwsurfer   User is offline

  • D.I.C Regular
  • member icon

Reputation: 21
  • View blog
  • Posts: 385
  • Joined: 24-October 06

Re: pulling from MySQL

Posted 22 February 2019 - 08:35 AM

DJPRiZM, what is the interface that you are using? and/or what programming language is being used form the SQL statements?
Was This Post Helpful? 0
  • +
  • -

#4 DJPRiZM   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 20-February 19

Re: pulling from MySQL

Posted 22 February 2019 - 01:11 PM

View Postajwsurfer, on 22 February 2019 - 08:35 AM, said:

DJPRiZM, what is the interface that you are using? and/or what programming language is being used form the SQL statements?


PHP
Was This Post Helpful? 0
  • +
  • -

#5 astonecipher   User is offline

  • Senior Systems Engineer
  • member icon

Reputation: 2996
  • View blog
  • Posts: 11,539
  • Joined: 03-December 12

Re: pulling from MySQL

Posted 25 February 2019 - 12:21 PM

https://phptherightw.../#pdo_extension
Was This Post Helpful? 0
  • +
  • -

#6 ajwsurfer   User is offline

  • D.I.C Regular
  • member icon

Reputation: 21
  • View blog
  • Posts: 385
  • Joined: 24-October 06

Re: pulling from MySQL

Posted 28 February 2019 - 08:46 AM

OK, it looks like the string is missing a semicolon on the end.

I would print out the string and copy and paste it into something like MySQL Workbench or HeidiSQL, in order to test it.
In PHP:
  print " **** SQL String: ".$sql



The MySQL syntax is as such (if <parameter> is not a number, then it needs to be '<parameter>'):
  SELECT <fieldName> FROM <tableName> WHERE <filterFieldName> = <parameter>;


would become:
  SELECT url FROM catalog_product_entity_varchar WHERE value_id = 147;


Was This Post Helpful? 0
  • +
  • -

#7 astonecipher   User is offline

  • Senior Systems Engineer
  • member icon

Reputation: 2996
  • View blog
  • Posts: 11,539
  • Joined: 03-December 12

Re: pulling from MySQL

Posted 28 February 2019 - 09:39 AM

Except we don't want to support sql injection capable programming...
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1