ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

tables in database

March 24, 2011 9:01pm

Subscribe [2]
  • #1 / Mar 24, 2011 9:01pm

    johnnyb

    45 posts

    I’m a PHP and SQL newbie. By inspecting the following template code in the EE site I inherited, I was able to find the name of a table/array, (order_info) used in our shopping cart template:

    // put Credit Card info into database
    $cmd = “INSERT INTO order_info VALUES(’‘, ‘$fullName’, ’” . base64_encode($cardNumber) . “‘, ‘$expireDate’, ‘$theTime’, ‘$cvv’)”;
    $cmdResult = mysql_query($cmd) or die(mysql_error());

    I figured out how to use CP/ADMIN/Utilities/SQL Manager/Database Query Form to run SELECT * FROM order_info to view the contents of this table, and even how to APPEND a column to hold the cvv number from the back of the credit card.  Once I had the table/array, it was fairly easy. The problem was finding the table/array.

    My question is, isn’t there some way to get a list of all the tables/arrays in the database? Going through all the code to find them takes forever.  I tried CP/ADMIN/Utilities/SQL Manager/Database Manager but it doesn’t list order_info, just a whole lot of things like exp_members. I thought, maybe order_info is recreated fresh every time there’s an order, but that’s not true - it accumulates orders from different customers until they are downloaded and cleared. Before SQL, there were commands like “list databases” or “list tables.”  How do you do that in SQL?

    In a similar vein, is there some way to see variables or string values?  This is related to a more pressing problem.  The same shopping cart template has an algorithm to set a discount price up to a month before the date of a seminar. The code is:

    thetime= time()

      if($_POST[‘Conference’] == ‘Conference April 22, 2011’
        && $thetime <  mktime(24, 0, 0, 3, 22, 2011)) {
    $theprice = '150.00';
    }
      elseif($_POST[‘Conference’] == ‘Conference October 4, 2011’
            && $thetime <  mktime(24, 0, 0, 9, 4, 2011)) {
    $theprice = '150.00';
    }
      else {
        $theprice = ‘175.00’;

    This has worked for years without problems - all I’ve had to do is change the dates each year. But suddenly, the price for the upcoming April 22 conference hasn’t changed from $150 to $175. I can’t figure out what’s wrong, as no matter what values I assign to $theprice, it always stays at $150 in the shopping cart. Isn’t there some way to view the value of $theprice and mktime as I run the code?  Some list of variables and values and strings and their current values, or a way to view them?

    Thanks

  • #2 / Mar 25, 2011 12:28pm

    Sue Crocker

    26054 posts

    Hi, johnnyb.

    order_info is something that isn’t native to EE tables, all of the EE tables start with exp_ something.. this table must be created by a third party add-on of some kind.

    You can find what is in a database table from within EE by doing the following:

    desc name_of_table

    But inside of EE, only the tables with the exp_ prefix will be shown. So you’ll need to use something like PHPMyAdmin for that.

    Does that help?

  • #3 / Mar 25, 2011 12:58pm

    johnnyb

    45 posts

    Hi, Sue. Thanks for replying.

    If I understand you, the Database Manager in CP shows only native EE tables.
    Yes, order_info is created in the shopping cart PHP. I can access it with SELECT, but only because I searched the code and figured out it was there.

    PHPAdmin is probably exactly what I need. Or some kind of SQL manager.

    That being said, what do you mean, “doing” the following?  Where am I supposed to enter the command “desc name of table”?

  • #4 / Mar 25, 2011 1:08pm

    Sue Crocker

    26054 posts

    Hi, johnnyb. Let’s get you a few screen shots so it’s easier to see what I’m talking about.

    Do these help?

  • #5 / Mar 25, 2011 1:33pm

    johnnyb

    45 posts

    😊 Oh yes, that helped a lot. Took me a sec to figure out I should put in “order_info” for “name of table,” but once I did, I got the data right away.  Thanks!

    DESC seems to be an SQL Plus command. It’s not in the basic list of commands in W3C School for SQL. Is there a reference or tutorial for all SQL functionality in EE? That would be really helpful.

    I still need to find some way to see the current values of MKTIME and $theprice. Please take another look at the code snippet and tell me whether you think that’s more of a PHP or SQL thing, and what I might be looking to do in a PHP or SQL manager.  It’s really strange. I’ve set $theprice manually to a totally different value, like $180, right in the ELSE statement - even commented out the IF statements entirely - and the value $150 still shows up in the shopping cart, as if I’d done nothing. I don’t know where that’s coming from, but my client is losing money every day this isn’t solved.  😖

  • #6 / Mar 25, 2011 1:42pm

    Sue Crocker

    26054 posts

    Hi, Johnny. I’m not sure if there is such a tutorial. I’ve just picked up some things over the years. (Used to do a LOT of Access programming/VB back in the day.)

    It’s a PHP thing. Unfortunately we (tech support) can’t really help with these kinds of questions, you’d need to post in the Development or CodeShare Corner forum.

    Which cart are you using?

  • #7 / Mar 25, 2011 4:09pm

    johnnyb

    45 posts

    Thanks again Sue. So good to get a helpful response.  I don’t know what the cart is, or how to find out. All I have is the code, inherited from a developer who’s apparently passed away, and there’s no source attribution at the top. So far I’ve been really lucky at tweaking it without really understanding it, but now I’m up the creek without the vaguest paddle.  Thanks for the tip re: Development or CodeShare Corner. I thought I’d have to be a super EE expert to post there.

    I’ve been wrestling with the idea of installing phpMyAdmin for some time, but it seems incredibly complicated, and from what I understand, I’d have to install it on the server too, and fine-tune it for the site.  Doesn’t EE have a php editor already in the package?  I would think EE would include both php and sql editing capabilities by default.

  • #8 / Mar 27, 2011 6:33am

    Sue Crocker

    26054 posts

    Johhny, EE doesn’t include an editor, you can work with external files for your templates, and use whatever editor you prefer.

    For instance, I use both Mac and Windows, and use UltraEdit for both since there are cross platform versions.

    If you don’t want to install PHPMyAdmin, there are several other programs you can use.

    One is MySQLDumper.net

    One thing you may not realize about EE yet is that normally you don’t have to fiddle with PHP code. You do most of your work inside of templates and by creating entries that are displayed by templates.

    If you want to use PHP, it’s normally as a part of a template.

    Or, you can use PHP to create modules, plugins, extensions and accessories.

    Since you have a unique need to maintain a legacy PHP based application, we really (as far as official support goes) be unable to help you with it. But we have many, many other members of the community that may be able to lend a hand.

    Might you be able to shorten your learning curve by converting over to one of the available carts for EE2?

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases