Jump to content
Larry Ullman's Book Forums

1cookie

Members
  • Posts

    24
  • Joined

  • Last visited

Posts posted by 1cookie

  1. There is also no mention in the book of edit_page.page, so are you mistaken or i am mistaken?

     

    No, there is no mention of

    edit_page.page
    

    but, like I said

    edit_page.php
    

    IS mentioned. From page 311:

    <h1><span><?php echo $page->
     getDateAdded(); ?></span><?php
     echo $page->getTitle(); ?></h1>
    <?php echo $page->getContent(); ?>
    <?php if ($user && $user->
     canEditPage($page)) {
    echo '<p><a href="edit_page.
    php?id='. $page->getId() .
     '">EDIT</a></p>';
    } ?>
    

    and from the scripts:

    <!-- # page.html - Script 9.10 -->
    <section class="fullWidth">
        <article>
            <h1><span><?php echo $page->getDateAdded(); ?></span><?php echo $page->getTitle(); ?></h1>
            <?php echo $page->getContent(); ?>  
            <?php if ($user && $user->canEditPage($page)) {
            echo '<p><a href="edit_page.php?id=' . $page->getId() . '">EDIT</a></p>';
            } ?>
        </article>
    </section>
    

    Last time I checked, it *wasn't* there!

  2. Do you need to use stored procedures, though, 1cookie?

     

     

    You're right, it's staring me right in the face. URL params is a better way me thinks.

     

    This seems very limiting and rigid to me. What if you want to incorporate some new clauses? What might be a better idea is a standard GET-based search where search query alters by the param. As an example, how about:

     

    domain.com/search.php?brand=nudie jeans

    domain.com/search.php?category=new

     

    I'm not sure if this is really a better idea,

     

    Do you mean like a bootstrap (index.php) file for instance? Similar to:

     

    if (isset($_GET['p'])) {
    $p = $_GET['p'];
    } elseif (isset($_POST['p'])) { // Forms
    $p = $_POST['p'];
    } else {
    $p = NULL;
    }
    switch ($p) {
    case 'price':
     $page = new Price;
     break;
    
    case 'size':
     $page = new Size;
    	 break;
    
    case 'colour':
     $page = new Colour;
     break;
    
    default:
     $page = new Main;
     break;
    
    } // switch.
    if (!is_object( $page)) {
    $page = new Main;
    
    }
    include('./includes/header.html');
    $page->load();
    
    include('./includes/footer.html');
    

     

    as an example.

     

    looking at the larger websites, they use URLs like:

     

    http://www.example.com/men/jeans#catalogId=10001&lid=//productsuniverse/en_GB/product_online%3DY/categories%3C{productsuniverse_18664}/categories%3C{productsuniverse_18664_18546}/categories%3C{productsuniverse_18664_18546_18551_ms}&ps=default&sfn=CATEGORIES&sfv=Bootcut&storeId=10001
    

     

    Just for the record, I'm not looking to code the next Magento site here (I'm not nearly clever enough), it's the small scale stuff that I'm learing with to start with.

     

    but that is what my sleep deprived brain would have done. Btw. It would be easy to include searches on all clauses, add filters and that kind of stuff with such a solution. If I'm not very good at explaining my thoughts, I can write a short demo tomorrow.

     

    That sounds interesting, I look forward to that. I'm doing this in my spare time in between work hours so forgive the pauses; although its going around in my head most of the time :). For the URLs - If we were talking about frameworks we'd be talking about routes no doubt. I'm not looking to implement a framework though. I am looking to code it as a collection of objects or OOP however.

  3. Ok, I thought you were struggling with something here. If you want a general discussion on your ER-diagram, sure we can do that. From the looks of it, your models look pretty good. However, there are some things that bother me a little bit here, or that I want to ask you about.

     

    1. The table Prices. I don't get that entity. You should store the prices as floating point numbers. Your current solution is a one-to-one relationship that does not make sense to normalize. If you need the price table in another setting, do that, but remove the relationship to products.

    2. Categories in products. Could some jeans fit in several categories? Might be worth thinking about.

    3. Stock. This one is a bit tricky, so discard me if it's the wrong approach. A single pair of Jeans might come in 10 colors and 5 sizes. Currently, you would need to add 50 products. This is too complex to figure out while on the train, but you should think about this one. Is there a way to add a generalized jeans product and then add size, color and numbers of jeans? I don't know if that would work for you, but it would make many things easier.

     

    Hope that was closer to what your after.

     

    thanks.

     

    Yes, I could scratch the prices table maybe you have a point. A price should be in the Product table. I'm more comfortable with the singular term 'Product' as opposed to 'Products'.

     

    I'm going to stick with categories and products as separate entities. One category can have multiple products and a single product belongs in one category: one to many.

     

    Not sure about stock yet, mulling that over.

     

    For me I really want to be able to search on: category, designer, price, size and colour and so am torn between the stored procedure call and database model.

     

    My Stored Procedure SP may be similar to:

     

    DELIMITER $$
    CREATE PROCEDURE select_products(type VARCHAR(40), cat TINYINT)
    BEGIN
    IF type = 'category' THEN
    SELECT ...
    FROM product AS p
    INNER JOIN category AS c ON p.id=c.category_id 
    WHERE c.category_id=cat AND stock>0
    ORDER by name ASC;
    ELSEIF type = 'designer' THEN
    SELECT
    FROM product AS p
    INNER JOIN designer AS d
    ON p.id=d.designer_id
    WHERE designer_id=cat AND stock>0
    ORDER by date_created DESC;
    ELSEIF type = 'colour' THEN
    SELECT
    FROM product AS p
    INNER JOIN colour AS col
    ON p.id=col.colour_id
    WHERE colour_id=cat AND stock>0
    ORDER by DESC;
    ELSEIF type = 'size' THEN
    ...
    
    END IF;
    END$$
    DELIMITER ;
    

     

    unchecked draft of course. I would then have multiple forms in the front end to get the users interaction, filtering my SP results by any of the variables mentioned.

     

     

     

    <select name="price">
    <option value="19.99">19.99</option>
    <option value="29.99">29.99</option>
    <option value="39.99">39.99</option>
    <option value="49.99">49.99</option>
    </select>
    <select name="colour">
    <option value="red">red</option>
    <option value="stonewash">stonewash</option>
    <option value="tan">tan</option>
    </select>
    <select name="size">
    <option value="32L">32L</option>
    <option value="33M">33M</option>
    <option value="34S">34S</option>
    </select>
    

     

    This is just off the top of my head. Good comments so far; thanks again for the help.

  4. The examples should be perfectly trasferable to other type of products too.

    Indeed. And I acknowlege that. That's the idea of open source you share ideas collaboratively.

     

    Read the parts you did not fully get another time,

     

    I didn't say I'm struggling to understand or didn't get something. Although examples in the book are pretty rigorous from the start they're well taught by the author. That's not to say they couldn't become more difficult pretty quickly. For instance, in my denim jeanshop example, my revised products table may look like:

     

     

    -- -----------------------------------------------------
    -- Table `default_schema`.`products`
    -- -----------------------------------------------------
    CREATE  TABLE IF NOT EXISTS `default_schema`.`products` (
     `id` MEDIUMINT(8) UNSIGNED NOT NULL AUTO_INCREMENT ,
     `category_id` TINYINT(3) UNSIGNED NOT NULL ,
     `size_id` TINYINT(3) UNSIGNED NOT NULL ,
     `colour_id` TINYINT(3) UNSIGNED NOT NULL ,
     `designer_id` TINYINT(3) UNSIGNED NOT NULL ,
     `price_id` TINYINT(3) UNSIGNED NOT NULL ,
     `name` VARCHAR(60) NOT NULL ,
     `description` TINYTEXT NULL DEFAULT NULL ,
     `image` VARCHAR(45) NOT NULL ,
     `price` DECIMAL(5,2) UNSIGNED NOT NULL ,
     `stock` MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0' ,
     `date_created` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ,
     `categories_id` TINYINT(3) UNSIGNED NOT NULL ,
     `designers_id` TINYINT(3) UNSIGNED NOT NULL ,
     `prices_id` TINYINT(3) UNSIGNED NOT NULL ,
     PRIMARY KEY (`id`) ,
     INDEX `category_id` (`category_id` ASC) ,
     INDEX `fk_products_categories` (`categories_id` ASC) ,
     INDEX `fk_products_designers1` (`designers_id` ASC) ,
     INDEX `fk_products_prices1` (`prices_id` ASC) )
    ENGINE = MyISAM
    DEFAULT CHARACTER SET = utf8;
    

     

    as you can see, we have a lot more foreign keys here for starters. This would make the stored procedures more complex for sure. But alas I'm not trying to get into a flex your muscles dialogue here, more peoples opinions or insights really.

  5. hi

     

    Interesting book especially the stored procedures. I'd be interested to hear from anyone who is interested in extending or generalising the database; thus creating more variables to search upon. After all, not all of us want to sell coffee do we? I'm especially interested in filters or searching by specific categories see:

     

    http://acookson.org/wp-content/uploads/2013/01/shop-screenshot.png

     

    for an example of what's on my mind.

     

    In my fictitional jeans shop example, I was playing around with MySQL workbench to come up with some possibilities for an ER diagram:

     

    http://acookson.org/wp-content/uploads/2013/01/ecommerce3.png

     

    It's totally at prototype stage and was looking for some inspiration really; maybe an on-going discussion around this topic.

     

    best wishes

     

    Andrew

  6. In xampp, it's in the settings you get to from the sidebar's homescreen. It comes with it's own test certificate (it will light your browser up with warnings like a christmas tree, but it works for testing). So I haven't messed with lamp, but I did find this:

    http://www.phpjoel.c...wamp-localhost/

     

    thanks.

     

    What I have learnt is that if you want SSL encryption on ones localhost machine then it's going to involve creating your own digital certificates.

  7. hi

     

    I'm just at page 282, chapter 10. Now you can test the checkout.php process. If you fill out the form incorrectly, it will be displayed again (Figure 10.13). If you fill it out correctly, you'll be sent to billing.php, which will be written next.

     

     

    I can't get to checkout.php over https on my localserver?

     

    https://localhost/coffeeLatte/checkout.php?session=c3e7255a9ec227b4c73b39af5c726792
    

     

    Is this as expected?

  8. hi

     

    This is not a critisism in any way - rather a query regarding table types: MyISAM & INNODB resp. Part two of the good book we get into some advanced MySQL i.e. stored procedures. The procedure (well the first anyway) I'm curious about is:

     

    select_sale_items(get_all BOOLEAN)
    

     

    I'm not a MySQL expert by any means so am appealing to the RDBMS gurus really. My question is regarding table locking. What if my database has 1000 records in the sales and non_coffee_products tables say. Then 3000 people log on to my site and all head for the sales page simultaneosly.

     

    The tables in the procedure above are of type MyISAM and MyISAM locks tables whilst INNODB locks rows. Will this cause problems in my hypothetical scenario?

     

    I ran

    get_sale_items(true)

    at home with six records in the database and it executes in (0.00) sec, fast! Would a production version differ significantly?

     

    Would the query make it to the MySQL slow-query.log with a slow query being > 1 sec?

     

    :)

  9. hi

     

    I'm starting to look at Part Three of the good book - Selling Physical Products. I'd like to implement something similar to Larry's model/application - widgets say. But first I'd like to test it somewhere (cheapest) before I go live!

     

    1. Do I HAVE to have SSL? Could I do it using http instead?

    2. Is a shared host OK to start/test with?

     

    For 1. Is this determined by my gateway provider?

     

    Just trying to get a feel for it. I'd probably start off with a test domain: http://test.example.com say.

     

    :rolleyes:

  10. For those of you have experienced a problem with integrating PayPal. This seems to be an issue with accounts in GBP. But this is the way around it:

     

    - Login to your seller sandbox account => So just check the radio box and click "enter sandbox test site"

    - Click on Profile

    - Click on My saved buttons

    - Click on create new button link

    - Follow the steps on the page to create a new button in your sandbox account.

     

    - When you save the button you can go back to the my saved buttons page to see your buttons.

     

    Hope that helps clear this problem up.

     

    hi Jonathon

     

    Just to be pedantic, the route to take (for me it seemed) is actually: Profile > My Account Settings, under the Selling Preferences header click the link My Saved Buttons link. But hey, thanks a million for that! I can now continue with testing my site. :rolleyes: I tell you what, I'm not feeling the love from Paypal.

     

    Here's my dialog with them:

     

    Response Chad C 07/14/2011 02:27 PM

    Hello Andy Cook,

     

    Your issue is still being looked into, and you will be updated through the ticket that is currently open.

     

     

    Sincerely,

    Chad

    Merchant Technical Support

    PayPal, an eBay Company

     

    Discuss PayPal technology, share code samples and stay current on the latest developer news at https://www.x.com/

    Response Administrator 07/14/2011 11:15 AM

    Thank you for contacting us about your issue on the PayPal Site.

     

    We have reviewed your issue and we are working to get an update to you.

     

    Sincerely,

    Merchant Technical Support

    PayPal, an eBay Company

    Customer Andy Cook 07/14/2011 10:36 AM

    I'm sorry but you didn't reply to my query??

     

     

    and they changed the status of the ticket to 'solved' TWICE!! With clearly no solution!

  11. This seems a bit strange to me. I've never been on the PayPal business pages, if those actually belong to PayPal. It's got a valid certificate, but the address of the registrar is different.

     

    hi Larry

     

    Great book so far! Yes, this is indeed very strange. I wonder if it's a Paypal glitch? Anyways, I've posted a question on their developer forums...let's see what they come back with. :blink:

  12. hi

     

    I've logged in to

    https://developer.paypal.com/cgi-bin/devscr?cmd=_sandbox-acct-session

    and successfully created two fictitious accounts: merchant and buyer. On this page I check the radio button for the merchant account, click through on Enter Sandbox Test Site and sure enough, I'm at:

    https://www.sandbox.paypal.com/uk/cgi-bin/webscr?cmd=_login-done&login_access=1310316861

    nb: the sandbox.

     

    Next up login as the merchant

    https://www.sandbox.paypal.com/uk/cgi-bin/webscr?dispatch=5885d80a13c0db1f8e263663d3faee8d422be6d275c375afb284863ba74d6cdc

    .

     

    Once at this page, if I click the Merchant Services tab URL:

    https://www.sandbox.paypal.com/uk/cgi-bin/webscr?cmd=merchant&nav=3

    The browser redirects me to:

    https://www.paypal-business.co.uk/merchantservices/index.htm

    so according to the URL it appears I'm no longer in sandbox?

     

    On this page I click on the Sell subscriptions link; to create a button 'naturally'. So we're at the creating buttons screen, now, Step 1 is active although there is no option for Merchant account IDs

    or radio buttons:

    > Use my secure merchant account ID

    and

    > Use my primary email address seller_5764539586_biz@mac.com

     

    Moreover Step 2 track inventory & 3 customise advanced features, and none of the functionality is active - just You need to 'login' or 'signup' links. What happened? I can't get past this point!

     

    I should be seeing something similar to figure 6.7 in the book but this is not the case?

     

     

    Has anyone had similar problems??

     

    edit:

     

    Using this as an example. I'm at screenshot 3 OK, but when I try to click through to screenshot 4 (Merchant Services page) my browser redirects me to:

    https://www.paypal-business.co.uk/merchantservices/index.htm

    , a completely different page?? And the options that i need to successfully create my button aren't there??

     

     

     

     

     

    help... <_<

  13. Quickly looking at this you're right. I would guess Larry does it like that as there are times you will have various foreign keys within one table and it's just a clearer way to to workout what the key represents.

     

    So just to reinforce that:

     

    Naming conventions are a matter of preference - but both fields MUST be of the same data type?

  14. hi

     

    First a quick example to explain my thoughts. Let's say I have two tables: customer and order. Now a customer can make many orders and an order is associated with one customer - one-to-many relationship. In MySQL I'm used to seeing relations like the following:

     

    customer = {cust_id, f_name, s_name, ...., dob,...} & order = {ord_id, cust_id, ord_content, ord_total,..., ord_date,...} say. Where the cust_id is the link (foreign key) between the two tables. My point here is that the two fields are named the same and would be of the same data type. This is how I'm used to seeing one to many relationships in MySQL.

     

    Is this purely a matter of preference?

     

    I mean, from Larry's book, I have the following two tables:

     

    CREATE TABLE IF NOT EXISTS `categories` (
    `id` smallint not null auto_increment,
    `category` varchar(30) not null,
    PRIMARY KEY (`id`),
    UNIQUE KEY `category` (`category`)
    ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
    

     

    CREATE TABLE IF NOT EXISTS `pages` (
    `id` mediumint unsigned not null auto_increment,
    `category_id` smallint unsigned not null,
    `title` varchar(100) not null,
    `description` tinytext not null,
    `content` longtext not null,
    `date_created` timestamp not null default current_timestamp,
    PRIMARY KEY (`id`),
    KEY `category_id` (`category_id`),
    KEY `creation_date` (`date_created`)
    ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
    

     

    where a category can have many pages and one page belongs to one category - 'one-to-many'. Only, from the book I don't see matching field names (foreign key)? I mean where's the foreign key in this relationship? Is it between id in categories and category_id in pages? Bearing in mind they are of the same data type.

     

    Can someone clarify.

×
×
  • Create New...