Jump to content

ricmetal

Members
  • Posts

    351
  • Joined

  • Last visited

Posts posted by ricmetal

  1. hi

    yes, thanks

     

    i added p.external_url to the top line @

    $query = $this->db->query("SELECT DISTINCT *, pd.name AS name, p.image, p.external_url, m.name AS manufacturer, 
    

    and added the external_url variable in the array:

    return array( 
      'product_id'       => $query->row['product_id'],
      'external_url'     => $query->row['external_url'],
    

    however, i managed to get the data to show today.

    turns out i was outputting the wrong variable name (the variable which had the data in the array above)

    thanks!

  2. hi guys

    im looking into making a little modification to my open cart store but i need help cause im not fluent in advanced sql queries...

     

    the line i need changed is the following:

    $query = $this->db->query("SELECT DISTINCT *, pd.name AS name, p.image, m.name AS manufacturer, (SELECT price FROM " . DB_PREFIX . "product_discount pd2 WHERE pd2.product_id = p.product_id AND pd2.customer_group_id = '" . (int)$customer_group_id . "' AND pd2.quantity = '1' AND ((pd2.date_start = '0000-00-00' OR pd2.date_start < NOW()) AND (pd2.date_end = '0000-00-00' OR pd2.date_end > NOW())) ORDER BY pd2.priority ASC, pd2.price ASC LIMIT 1) AS discount, (SELECT price FROM " . DB_PREFIX . "product_special ps WHERE ps.product_id = p.product_id AND ps.customer_group_id = '" . (int)$customer_group_id . "' AND ((ps.date_start = '0000-00-00' OR ps.date_start < NOW()) AND (ps.date_end = '0000-00-00' OR ps.date_end > NOW())) ORDER BY ps.priority ASC, ps.price ASC LIMIT 1) AS special, (SELECT points FROM " . DB_PREFIX . "product_reward pr WHERE pr.product_id = p.product_id AND customer_group_id = '" . (int)$customer_group_id . "') AS reward, (SELECT ss.name FROM " . DB_PREFIX . "stock_status ss WHERE ss.stock_status_id = p.stock_status_id AND ss.language_id = '" . (int)$this->config->get('config_language_id') . "') AS stock_status, (SELECT wcd.unit FROM " . DB_PREFIX . "weight_class_description wcd WHERE p.weight_class_id = wcd.weight_class_id AND wcd.language_id = '" . (int)$this->config->get('config_language_id') . "') AS weight_class, (SELECT lcd.unit FROM " . DB_PREFIX . "length_class_description lcd WHERE p.length_class_id = lcd.length_class_id AND lcd.language_id = '" . (int)$this->config->get('config_language_id') . "') AS length_class, (SELECT AVG(rating) AS total FROM " . DB_PREFIX . "review r1 WHERE r1.product_id = p.product_id AND r1.status = '1' GROUP BY r1.product_id) AS rating, (SELECT COUNT(*) AS total FROM " . DB_PREFIX . "review r2 WHERE r2.product_id = p.product_id AND r2.status = '1' GROUP BY r2.product_id) AS reviews, p.sort_order FROM " . DB_PREFIX . "product p LEFT JOIN " . DB_PREFIX . "product_description pd ON (p.product_id = pd.product_id) LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) LEFT JOIN " . DB_PREFIX . "manufacturer m ON (p.manufacturer_id = m.manufacturer_id) WHERE p.product_id = '" . (int)$product_id . "' AND pd.language_id = '" . (int)$this->config->get('config_language_id') . "' AND p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "'");
    

    i need to retrieve the column 'external_url' (which ive added) and is in the same database as 'image' (right near the beginning of the query (p.image))

    ive tried adding p.external_url after p.image but i couldnt retreive the data.

     

    the code that populates variables with the data retreived is:

    if ($query->num_rows) {
    			return array(
    				'product_id'       => $query->row['product_id'],
    				'name'             => $query->row['name'],
    				'description'      => $query->row['description'],
    				'meta_description' => $query->row['meta_description'],
    				'meta_keyword'     => $query->row['meta_keyword'],
    				'tag'              => $query->row['tag'],
    				'model'            => $query->row['model'],
    				'sku'              => $query->row['sku'],
    				'upc'              => $query->row['upc'],
    				'ean'              => $query->row['ean'],
    				'jan'              => $query->row['jan'],
    				'isbn'             => $query->row['isbn'],
    				'mpn'              => $query->row['mpn'],
    				'location'         => $query->row['location'],
    				'quantity'         => $query->row['quantity'],
    				'stock_status'     => $query->row['stock_status'],
    				'image'            => $query->row['image'],
    				'manufacturer_id'  => $query->row['manufacturer_id'],
    				'manufacturer'     => $query->row['manufacturer'],
    				'price'            => ($query->row['discount'] ? $query->row['discount'] : $query->row['price']),
    				'special'          => $query->row['special'],
    				'reward'           => $query->row['reward'],
    				'points'           => $query->row['points'],
    				'tax_class_id'     => $query->row['tax_class_id'],
    				'date_available'   => $query->row['date_available'],
    				'weight'           => $query->row['weight'],
    				'weight_class_id'  => $query->row['weight_class_id'],
    				'length'           => $query->row['length'],
    				'width'            => $query->row['width'],
    				'height'           => $query->row['height'],
    				'length_class_id'  => $query->row['length_class_id'],
    				'subtract'         => $query->row['subtract'],
    				'rating'           => round($query->row['rating']),
    				'reviews'          => $query->row['reviews'] ? $query->row['reviews'] : 0,
    				'minimum'          => $query->row['minimum'],
    				'sort_order'       => $query->row['sort_order'],
    				'status'           => $query->row['status'],
    				'date_added'       => $query->row['date_added'],
    				'date_modified'    => $query->row['date_modified'],
    				'viewed'           => $query->row['viewed']
    			);
    		}
    

    again, i tried adding a line after 'image', but again without any results.

    any help?

    thanks

  3. i understand. my issue was that in thinking that the 404.php page would show up, in place of a nonexistent, typed-in url (by a user), and seeing that the 404.php file needs to include elements found across the folder tree, that i would need to target them using the full path. while this is correct, it is incorrect to think the nonexistent url would stay the same while the 404.php would be shown. i don't know why i was thinking that that is how it worked, but you see my logic in needing to use the full path, and why i brought htaccess into the picture.

     

    if a file is not found, show the custom 404.php error page. from the 404.php page, include another file to use elements found in different areas of the tree. and to target them from different locations where the 404.php would be shown, i'd need the full url.

     

    hehe

     

    so, it turns out that the htaccess redirect when a page is not found actually redirects the url to the custom 404.php page instead of 'moving' the 404 file to the current location the user is.

     

    HENCE, liking to automatically set the root of the website to where the htaccess file is. Seeing htaccess is complicated as chinese algebra and a little bit of Dead Space moon talk, i decided to hardcode the website's root folder in the htaccess file and remember that the custom 404.php error page does not move places in the tree folder, hence, not needing to use ful url's to include other folders from the server tree, as well.

     

    and that is a wrap. this is what you get when you start building something in which you are a tad bit buried into too much of what you don't know, backed up with alot of what you'd like :)

    that and taking long breaks while doing so!

    cheers!

  4. i am trying to work with htaccess!

    trying to figure out how it works still - i thought i would need to use the full address but im more confused now that before lol

    i thought the 404 custom error page would keep the original url the user typed in (the failed url, hence the 4040 error) so the 404 error page would need to target elements scattered across the folder tree. thus the need for the include with full url.

     

    btw, regarding htaccess, does anybody know if it is at all possible to automatically make the folder in which the htaccess is, the root folder? i read alot of people using hardcoded url to set their base folders but i would like to have this automated if possible.

  5. hi guys

    so im trying to access a variable from an included php file, included using a full address, with http://www...

    but its not working.

     

    i read up on php manual but i dont get the answers

    im

    using php 5.3

    path is correct

    allow url is on

    included file is inclosed with php tags...

     

    could i get some help?

     

    here is the simple code i am using

     

     
    // included.php
    <?php
    $a = "data";
    ?>
     
    // main.php
    <?php
    include "http://www.somedomain.com/included.php";
    echo $a; // outputs nothing
    ?>
     
    

     

    what gives?

    gracias

  6. follow up thought:

    so i should always require a minimal mysql version as the latest possible to be able to install an app i create [on a server] - this way i can prevent code breaking. for instance in mysql 4.1 varchar had a limit of 255 characters. in versions after that it changed to 65k. image this being the other way around.

    if i always require the latest version of mysql to be used, i can prevent any code-breaking changes when installing the app in a server with a newer mysql version.

    i hope im not overthinking this but it makes sense, right?

  7. just went through the release note in a series of many MySQL versions existent between the one i currently use and the most recent ones.

    i have a follow up question: does MySQL work the same on Linux and on Windows?

    i ask this because i saw that i needed a different version requirement to run something, on Windows and Linux.

    what a mess

  8. so my server might upgrade its mysql version at anytime.

    what can i do to make sure my code wont break? where do i go to check all the changes made from version to version and is this usually a code-breaking problem?

    i cant image each mysql version breaking a bunch of code of 50million websites but we gotta be sure!

  9. so, they say data type TEXT can have up to 65k bytes. they also say the row limit is 65k. i read something along the lines that TEXT data type only takes up 8 or 9 bytes. is it empty? is the TEXT data type data being stored somewhere else other than in the row? please explain.

  10. i started out making a function to check for what i think is 'correct data in variables' in PHP

    seeing PHP's empty() function returns false when a variable is equal to zero, and i didnt want this.

    then i wanted to check a few global configuration variables for an app im building so i decided to port the function to javascript.

    that was the whole purpose.

     

    anyway, yes passing the variable name seems to do the trick. i dont quite understand the references but ill catch up

  11. because i wanted a generic function to check it a variable is undefined.

    ive tried and actually i think you cannot pass an undefined (undeclared) variable to a function through an argument.

    so i have long left that boat, so to speak. if any workaways to this id like to hear them though

    cheers

    regards

  12. im trying to find out if 

    a

     is defined.

     

    i used 

    objectName[prop] in objectName

     because simply 

    prop in objectName

     can't be resolved in the function, using the argument as the property.

  13. yes, i was using the literal value because thats how mozilla developer page presented it and it works in the global scope check so i  just left it there.

    but i realize i had to use the argument passed by the function thus the window[myVar].anyway, removing the quotes still doesnt work. nor checking for 'undefined' with typeof.

    from another user, that posted somewhere else, apparently we cannot check if global variables are undefined from within a function.

    and the tests ive made show this. at least to my knowledge i havent been able.

     

    i've been glancing over the mozilla developer docs, this is where i got the recommended 'best practice' to check for undefined using in

    https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/undefined

  14. i should mention that the variable im targeting has not been declared...

     

    im using

    if("myVar" in window) {}
    

    to check whether a variable has been declared, but this doesn't work from inside a function..any ideas why?

    function someFn(myVar){
      if("myVar" in window) { // also,      window[myVar] in window      works from within the function, as long as it has been declared. if it hasn't, i get no alert at all.
        alert('ok');
      } else {
        alert('not ok');
      }
    }
    

    i don't get any alert. if i haven't declared the variable....

     

    any ideas why?

     

    thanks

  15. hi guys

    ive been reading about checking for undefined variable checks it seems a good way is to use in window. its actually the only way i could make the check work..anyway, i really need to check foe an undefined variable outside a function's scope but using the in window method is not working. im not returning either false nor true.l

    how do i check if a variable [outside a function] is undefined, from within the function?

    the variable is passed as an argument.

    thanks

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.