Jump to content

gizmola

Administrators
  • Posts

    5,882
  • Joined

  • Last visited

  • Days Won

    139

Posts posted by gizmola

  1. You're not going to get a worthwhile answer without more information about what you're trying to do. 

    With that said, here's a few observations I have for you.  Oracle is a database that runs on just about every computing platform anyone is using, while mysql is predominately a unix program (although there is a windows and mac version).  Oracle has scalability features and a mature set of features that go substantially beyond what MySQL offers.  One of Oracle's great strengths is it's concurrency system, that by default offers versioning, known in Oracle terms as "read consistent views."  Basically, with Oracle, there is no need to have readers and writers contend with each other. For example, let's say that you are doing a query of a table of transactions in order to create a financial report.  The query needs to go through the entire table row, adding credits and subtracting debits.  In most databases, the solution to this problem is to put a "read" lock on the table, which would prevent updates from occurring to any of the rows of the table for the duration of the query.  If this was a large table, this locking period could really slow things down and be very undesirable for a high transaction system.  Suffice it to say, that Oracle doesn't require read locks of any kind, and that query runs fine and will not interrupt inserts, updates and deletes.  Oracle also offers highly functional stored procedures and triggers, including the ability to write sprocs in either pl/sql language or Java.  MySQL zealots love to debate this stuff, but point of fact there's a huge list of features Oracle has that MySQL doesn't, and probably won't anytime soon.  The thing that people typically point to is that MySQL's default mode (using the myisam engine) doesn't have support for transactions, or declarative referential integrity, both of which are meat and potatoes RDBMS features you find in about any other rdbms database (including Postgresql btw). 

    MySQL is a bit of an oddity in the relational database world.  It offers a unique feature that depending on how you look at it, is either a strength or a weakness: that of storage engines.  As I mentioned, MySQL's myisam engine doesn't support transactions, while the Innodb engine does.  This allows mysql to do some very cool things with specialized engines.

    Where PHP is concerned, MySQL has a property that works very well, in that PHP has page scope.  This means that PHP offers no persistence mechanism ... when a script runs it creates variables, and when that script is done, all the variables are garbage collected.  Because MySQL connections are very lightweight, there's almost no overhead in creating a MySQL connection, which works well with PHP's design.

    Oracle on the other hand, has a heavy connection process that can on the order of seconds.  Oracle has a session concept, and connections in general should be pooled and reused.  With Oracle, you make one connection if you need to do multiple queries, and issue the seperate queries using oracle sessions. Often people who don't understand this don't realize that they needed to use the ora_pconnect rather than the ora_connect.  There was almost no info on this in the old oracle client manual pages.

    Another key difference that helps with PHP is that MySQL's query execution process is far more lightweight in general use than Oracle's.  Oracle makes extensive use of query execution caching, however, the use of dynamically generated SQL statements as is common in PHP applications will result in very poor performance, because these statements will not be cached by Oracle.  Oracle requires the use of bind variables in order for Oracle to pull statements from it's query cache.  Many people find the work that you need to use bind variables to be tedious, although the increased interest in PHP security, and the development of PHP PDO are both developments that may have helped people appreciate the security benefits that can be had.

    Plainly speaking, PHP just didn't work very well with Oracle in the past, and was a bitch to get setup, requiring a pretty extensive understanding of Oracle, and the various client environment variables and client libraries.  In comparison, getting PHP setup with MySQL was simple and easy. 

    In the past couple of years, Zend entered into some agreements with Oracle post PHP 5, and work on integration with the Oracle library was stepped up significantly.  Part of that was a rewrite of the oracle client library to support 8,9 & 10 features, and BLOB types.  This client offers additional functions, as well as a variety of variables that allow you to tune connection caching, along with articles you can find on the Oracle Technology network, using PHP with Oracle is a lot more viable than it used to be.
  2. Yes, this is a common design.  There are several different paths depending on how you want to approach this.  To tell the truth this is something that isn't Oracle specific at all, but comes down to basic web application design.  In general there are frameworks out there that feature Model View Controller design pattern architectures that handle this.  I'm not going to get into all that, but I figured I'd at least mention it as best practice.

     

    Assuming you want to keep it simple, the simplest solution is to write a new script which takes as a URL parameter, the ISBN number, or whatever primary key for the catalog you'd specify in your WHERE clause.

     

    So your url should be something like:

     

    
    echo "";
    
    ?>
    

     

    In your showdetail.php, the first thing you would do is take this url parameter and set it to a variable you can then inject into your WHERE clause for the detail lookup.

     

    
    $isbn = (int) $_GET['isbn'];
    
    ?>
    

  3. I'm confused... where is the column that indicates which band these settings are pertinent to, or is this a cms application where the assumption is that someone will run this application on their website?

     

    The answer to your specific question is that I would probably just select all settings, and I would write a routine that would read all these settings into an array.  With that said, if you want to stay with what you have, the 2nd approach is definately an improvement (one query vs. 2) .

  4. There's a few different ways to accomplish this.  The first thing I noted is you used an unusual keying system where your service_id appears to be a letter.  This is a bad design for many reasons, not the least of which is that have to manually figure out the next visit using either ascii numbering or some hard coded alphabet system.  Your sample data also doesn't seem to make sense: for example you have the same car with two different visits on the same day.  Did you really have the same car on the same day with two different service visits?  Also do you really want the design to allow for only one thing to be done on one visit?  I'm guessing not.

     

    If this is an academic exercist, then that is one thing, if it's a production system, then the problems with your design are more important to fix than the answer to this one query.

     

     

  5. Although technically even Data definition language (DDL) is a "query" that's only issued when the table is created.  In selects and updates you would never use unsigned, as the concept of data typing of columns is not usually relevant once the table has been created.

     

    MySQL is similar to SQL Server in that it has byte length oriented numeric datatypes.  The types match the number of bytes used to store the value, so in your example, the int type is a 4 bytes (32 bit value).  Simple binary will reveal to you the largest value that can be stored with 32 bits. 

     

    By default if you you don't specify at create time, that you want an UNSIGNED int, you will get a signed int, where one of the 32 bits is reserved to indicate whether the value is + or -.  Effectively what this does is cut the maximum value range in half.

     

    I your example, you are creating the primary key of a table.  More often than not, people will also define that column to be Auto Increment.  With auto_increment you would never have a value that is minus, so it is a waste of storage to not used UNSIGNED as you lose 1/2 the potential maximum rows.  This means that you would run out of keys at 2,147,483,647 rows rather than 4,294,967,295.

     

    Very few databases require that number of rows, so this is largely academic for most people, although the same principle works for smaller data types like the smallint (64k) or tinyint(256) values.  One of the most important decisions you make in mysql design is correct data typing.  The smaller and more efficient the size of an individual row, the more efficient the database will be, all other things being equal.

     

    For example, if I have a lookup table that is going to store types of fruit, it's worth asking the question of what is the largest number of fruit I expect to ever have in that table.  In all probability, I will not be able to think of more than 256 different types of fruit, so an UNSIGNED TINYINT is a good type for the primary key of that table.

     

    As I relate that table to other tables in my database (think for example of a recipe database where I might indicate fruit and a quantity) that I may have thousands of rows of recipes that involve fruit, however in each one it only costs me 1 byte of storage to indicate the fruit as a foreign key.

     

     

  6. You need the Oracle jdbc driver.  This sample code sums it up pretty simply I think:

     

    Connection connection = null;
        try {
            // Load the JDBC driver
            String driverName = "oracle.jdbc.driver.OracleDriver";
            Class.forName(driverName);
        
            // Create a connection to the database
            String serverName = "127.0.0.1";
            String portNumber = "1521";
            String sid = "mydatabase";
            String url = "jdbc:oracle:thin:@" + serverName + ":" + portNumber + ":" + sid;
            String username = "username";
            String password = "password";
            connection = DriverManager.getConnection(url, username, password);
        } catch (ClassNotFoundException e) {
            // Could not find the database driver
        } catch (SQLException e) {
            // Could not connect to the database
        }
        
    
    

  7. [!--quoteo(post=376098:date=May 22 2006, 11:28 AM:name=Celardore)--][div class=\'quotetop\']QUOTE(Celardore @ May 22 2006, 11:28 AM) [snapback]376098[/snapback][/div][div class=\'quotemain\'][!--quotec--]
    Hey guys,

    I've been working on a new project for the past few days.

    [a href=\"http://www.heelyportal.com\" target=\"_blank\"]www.heelyportal.com[/a]

    The purpose of the site will be for heely skaters to be able to upload skating videos for all to be seen. Eventually it will also include generic tutorials, tips, forums etc.

    I seem to have a major issue with getting the sample video to play in IE... I don't know how to get around this, so if anyone has any tips!!! (quicktime plugin doesn't seem to function)
    Like I say, it's new so my feelings won't be hurt by a little critique of design / layout / function. Several features aren't working right now - just trying to sort the uploads but it's being a nightmare!

    Thanks for the tips.
    Celardore
    [/quote]


    I don't like your basic approach to "windowing". There's nothing wrong with a dark color scheme, although I would question the use of one for your particular site. Nevertheless, the way I like to think about a site is the site's "window" sits on top of a background. That background is sometimes an image, or just a basic color.

    The "window" should then be a different color, and one thing you should avoid is ever having panes that have the same color as the background color, because you're sending the message that there's a "hole" in your window.

    Your site is all black. So there's no sense that there is a "window" for your site. I don't think very many people will find it appealing, from a visual standpoint.

    You also have width and spacing issues. I have a large screen and the header, menu bar, and main content area don't line up.
  8. [!--quoteo(post=373120:date=May 10 2006, 03:34 PM:name=jasonc)--][div class=\'quotetop\']QUOTE(jasonc @ May 10 2006, 03:34 PM) [snapback]373120[/snapback][/div][div class=\'quotemain\'][!--quotec--]
    <?
    $email = "abc@def.ghi";
    $safeemail = mysql_real_escape_string($email);
    echo('.'.$safeemail.'.');
    ?>

    i get the following

    ..

    meaning that it does not store the email, what exactly does this command do?

    how do i catch weather the email is invalid or if the text in the membersname variable is only letters upper or lower case. and if it is not i can tell them to correct it before it is sent to the database.

    thanks
    [/quote]

    Pretty much just what the manual page says it does... escapes a variety of characters. This is a *smart* function in that it is integrated into the mysql API so that it can be intelligent about the mysql character set being used.

    So in your example. you are missing a mysql database connection handle. The handle is an implied 2nd param, that you can specify. Either way you need a mysql database connection in your script to really see what the function does.
  9. [!--quoteo(post=373148:date=May 10 2006, 06:14 PM:name=thorpe)--][div class=\'quotetop\']QUOTE(thorpe @ May 10 2006, 06:14 PM) [snapback]373148[/snapback][/div][div class=\'quotemain\'][!--quotec--]
    Ah cool. So... we all have them, but can only see our own unless we are a mod etc. Cool. Bit paranoid.... never noticed it before. ( and I know I can get a little hot headed at times)
    [/quote]

    It's a mechanism for group moderation that can eventually lead to automatic banning. When we have trouble with someone we can as mods raise their warning level. If it gets to 100% the person gets a ban.

    You can sleep easy, as your warn level is 0% -- you have never had a warning issued. When you do you recieve a PM, and the mod usually explains why they issued you the warning.
  10. [!--quoteo(post=367348:date=Apr 21 2006, 03:41 PM:name=niza)--][div class=\'quotetop\']QUOTE(niza @ Apr 21 2006, 03:41 PM) [snapback]367348[/snapback][/div][div class=\'quotemain\'][!--quotec--]
    I have a user registration area:
    new_member.php - script that executes the registration
    new_member.htm - contains the html registration form
    template.htm - html template

    If the user does not fill in all the required fields, new_member.htm is called in new_member.php, with the appropiate error message.

    Now, I have problems including my template.htm file.

    1.If I include it in the new_member.htm, whenever the user does not fill in the required fileds, the error message are displayed on top of the template.
    2.If I include it in the new_member.php, the form is not displayed properly.

    Any ideas?

    By the way, the script for user registration I am using is this: [a href=\"http://www.phpfreaks.com/tutorials/40/0.php\" target=\"_blank\"]http://www.phpfreaks.com/tutorials/40/0.php[/a]
    [/quote]

    I'm a bit confused as to what you're trying to do and why, and exactly what your problem is. Needless to say.. only PHP files will be parsed by the php interpreter server side. There is no way to include html files inside other html files without some server side language, so your description in that regards doesn't make much sense. Maybe it would help if you provided some source code.
  11. You seem to be clear on the idea that php has page scope, and that a script creates variables and destroys them when the script is done executing. Thus there is a need for persistence/session. This isn't unique to PHP at all -- it's the nature of web development due to the design of HTTP.

    To demystify PHP sessions, they are basically files stored on the server. When you create a session variable by assigning a value to it, that value is stored in a session file on the server. Once a session variable is created in Script A, script B can use it, so long as you session_start().

    The typical way this is achieved is that php assigns the browser/user a unique ID number called the session ID. This is what ties someone to a session. In most cases this ID is set as a cookie, which is why it appears that magically these otherwise invisible variables are persisting. The advantage over cookies alone is that the values don't have to cross the internet --- only the session ID is needed.

    Session variables are like any other variable in tnat you can change them or unset them. So your example above is exactly right.

    To remove a sessions variable called 'foo' --

    unset($_SESSION['foo']);

    This example assumes that register globals is off, which it should be these days ;)

    Read the session portion of the php manual for more info.
  12. [!--quoteo(post=367315:date=Apr 21 2006, 02:05 PM:name=Michael2k5)--][div class=\'quotetop\']QUOTE(Michael2k5 @ Apr 21 2006, 02:05 PM) [snapback]367315[/snapback][/div][div class=\'quotemain\'][!--quotec--]
    Hello! I was wondering if there is a way to easilly pull something from an XML file onto a page. If you could help that would be great! Thanks

    here is the code

    [code]<?xml version="1.0" standalone="yes" ?>

    <SHOUTCASTSERVER>
      <CURRENTLISTENERS>0</CURRENTLISTENERS>
      <PEAKLISTENERS>3</PEAKLISTENERS>
      <MAXLISTENERS>32</MAXLISTENERS>
      <REPORTEDLISTENERS>0</REPORTEDLISTENERS>
      <AVERAGETIME>547</AVERAGETIME>
      <SERVERGENRE />
      <SERVERURL>http://www.skynetx.com/radio/listen.php?dj=</SERVERURL>
      <SERVERTITLE>SkyNetX Radio</SERVERTITLE>
      <SONGTITLE>Rammstein - Laichzeit</SONGTITLE>
      <SONGURL />
      <IRC>#shoutcast</IRC>
      <ICQ>0</ICQ>
      <AIM>N/A</AIM>
      <WEBHITS>3501</WEBHITS>
      <STREAMHITS>141</STREAMHITS>
      <STREAMSTATUS>1</STREAMSTATUS>
      <BITRATE>96</BITRATE>
      <CONTENT>audio/mpeg</CONTENT>
      <VERSION>1.9.5</VERSION>
    <WEBDATA>
      <INDEX>12</INDEX>
      <LISTEN>0</LISTEN>
      <PALM7>0</PALM7>
      <LOGIN>0</LOGIN>
      <LOGINFAIL>5</LOGINFAIL>
      <PLAYED>0</PLAYED>
      <COOKIE>0</COOKIE>
      <ADMIN>30</ADMIN>
      <UPDINFO>1027</UPDINFO>
      <KICKSRC>1</KICKSRC>
      <KICKDST>3</KICKDST>
      <UNBANDST>1</UNBANDST>
      <BANDST>1</BANDST>
      <VIEWBAN>2</VIEWBAN>
      <UNRIPDST>0</UNRIPDST>
      <RIPDST>3</RIPDST>
      <VIEWRIP>3</VIEWRIP>
      <VIEWXML>2408</VIEWXML>
      <VIEWLOG>1</VIEWLOG>
      <INVALID>4</INVALID>
      </WEBDATA>
      <LISTENERS />
    <SONGHISTORY>
    <SONG>
      <PLAYEDAT>1145390097</PLAYEDAT>
      <TITLE>Rammstein - Laichzeit</TITLE>
      </SONG>
    <SONG>
      <PLAYEDAT>1145385323</PLAYEDAT>
      <TITLE>Rob Zombie - The Scorpion Sleeps</TITLE>
      </SONG>
    <SONG>
      <PLAYEDAT>1145385096</PLAYEDAT>
      <TITLE>Rob Zombie - American Witch</TITLE>
      </SONG>
    <SONG>
      <PLAYEDAT>1145384869</PLAYEDAT>
      <TITLE>Rob Zombie - 17 Year Locust</TITLE>
      </SONG>

    <SONG>
      <PLAYEDAT>1145384656</PLAYEDAT>
      <TITLE>Rob Zombie - Ride</TITLE>
      </SONG>
    <SONG>
      <PLAYEDAT>1145384649</PLAYEDAT>
      <TITLE>Rob Zombie - 100 Ways</TITLE>
      </SONG>
    <SONG>
      <PLAYEDAT>1145384467</PLAYEDAT>
      <TITLE>Rob Zombie - Foxy Foxy</TITLE>
      </SONG>

    <SONG>
      <PLAYEDAT>1145322513</PLAYEDAT>
      <TITLE>N.E.R.D. - Rock Star (Jason Nevins Remix Edit)</TITLE>
      </SONG>
    <SONG>
      <PLAYEDAT>1145322311</PLAYEDAT>
      <TITLE>Rob Zombie - American Witch</TITLE>
      </SONG>
    <SONG>
      <PLAYEDAT>1145322062</PLAYEDAT>
      <TITLE>Rob Zombie - Let It All Bleed Out</TITLE>
      </SONG>

    <SONG>
      <PLAYEDAT>1145321619</PLAYEDAT>
      <TITLE>Rob Zombie - The Devil's Rejects</TITLE>
      </SONG>
    <SONG>
      <PLAYEDAT>1145321411</PLAYEDAT>
      <TITLE>Rob Zombie - Foxy, Foxy</TITLE>
      </SONG>
    <SONG>
      <PLAYEDAT>1145314816</PLAYEDAT>
      <TITLE>System Of A Down - Forest</TITLE>
      </SONG>
    <SONG>
      <PLAYEDAT>1145314537</PLAYEDAT>
      <TITLE>System Of A Down - Holy Mountains</TITLE>
      </SONG>

    <SONG>
      <PLAYEDAT>1145301373</PLAYEDAT>
      <TITLE>N.E.R.D. - Rock Star (Jason Nevins Remix Edit)</TITLE>
      </SONG>

      </SONGHISTORY>
      </SHOUTCASTSERVER>[/code]

    yea so i want to easilly pull off parts of this, ex: <PEAKLISTENERS> that would be cool.
    [/quote]


    How to do this, and the relative ease with which it can be done is dependent on the version of php you have. If you have php5 then this should help you. [a href=\"http://us2.php.net/manual/en/ref.dom.php\" target=\"_blank\"]http://us2.php.net/manual/en/ref.dom.php[/a]

    PHP is a great tool for these types of things, and is well suited to webservices.
  13. [!--quoteo(post=367313:date=Apr 21 2006, 02:03 PM:name=anthropos9)--][div class=\'quotetop\']QUOTE(anthropos9 @ Apr 21 2006, 02:03 PM) [snapback]367313[/snapback][/div][div class=\'quotemain\'][!--quotec--]
    Hello,

    My hosting company just changed servers and ever since then I've been getting this error:

    Here is the relavant code to go along with this:

    <?php echo "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?".">"; ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <?php require("includes/connect.php");
    $id = $_GET['id'];
    $mid = $_GET['mid'];
    ?>

    Any help is welcome. Thanks.
    [/quote]

    I agree with bullmarky on this one. Those notices aren't errors, but rather warnings. The problem is that you're trying to reference 2 variables that won't exist unless they are passed to the script as url parameters. That may be a perfectly reasonable situation depending on what the script is suppossed to do.
  14. [!--quoteo(post=367324:date=Apr 21 2006, 02:22 PM:name=feri_soft)--][div class=\'quotetop\']QUOTE(feri_soft @ Apr 21 2006, 02:22 PM) [snapback]367324[/snapback][/div][div class=\'quotemain\'][!--quotec--]
    S o i must add this i n my query ?? ;)
    [/quote]

    Barand was as clear as he could be. MySQL Date columns have no Time component. If you need a Date + time in one column then you need to use a MySQL DateTime column. You can easily alter your table structure using ALTER TABLE to modify your DATE column to a DATETIME.

    If you're still confused try reading this: [a href=\"http://www.gizmola.com/blog/archives/51-Exploring-Mysql-CURDATE-and-NOW.-The-same-but-different..html\" target=\"_blank\"]http://www.gizmola.com/blog/archives/51-Ex...different..html[/a]


  15. [!--quoteo(post=367326:date=Apr 21 2006, 02:27 PM:name=HostFreak)--][div class=\'quotetop\']QUOTE(HostFreak @ Apr 21 2006, 02:27 PM) [snapback]367326[/snapback][/div][div class=\'quotemain\'][!--quotec--]
    What im trying to do is be able to select the agent name which is $username from the table users but have its value be the id_num. Here is what Im doing:

    [code]
    $query = "SELECT id_num FROM users WHERE userlevel = '8'";  
    $result = mysql_query($query);
    print "<SELECT name=id_num><option>Choose One</option>";
    while ($row = mysql_fetch_array($result))
        {
            extract($row);
            echo  "<option value='$id_num'>$id_num</option>";
        }
        mysql_close($link);
    print "</SELECT>";
    [/code]

    Im not sure how to exactly call the $username. Last time i tried it, it listed the username logged in for all the options. I guess because i didn't call it as a line or something.
    [/quote]


    First off, you can query more than one column in a single query, right?

    Try this code instead:

    [code]
    $query = "SELECT id_num, username FROM users WHERE userlevel = '8'";  
    $result = mysql_query($query);
    print "<SELECT name=id_num><option>Choose One</option>";
    while ($row = mysql_fetch_assoc($result))
        {
            echo  "<option value='{$row['id_num']}'>{$row['username']}</option>";
        }
        mysql_close($link);
    print "</SELECT>";
    [/code]

  16. [!--quoteo(post=367328:date=Apr 21 2006, 02:35 PM:name=michaellunsford)--][div class=\'quotetop\']QUOTE(michaellunsford @ Apr 21 2006, 02:35 PM) [snapback]367328[/snapback][/div][div class=\'quotemain\'][!--quotec--]
    Just some structure advice (maybe it's already built into mysql?)

    I have an address book table. Instead of using a freeform title field, I am using an integer field that records the keyfield from a titles table. When the people in the address book are displayed, I just convert the title's integer into the description recorded in the title's table.

    [code]$result=mysql_query("SELECT * FROM `contacts`");
    $title_result=mysql_query("SELECT * FROM `titles`");
    while($title_rows=mysql_fetch_assoc($title_result)) {
       $title[$title_rows['keyfield']]=$title_rows['value'];
    }
    while($my_contact=mysql_fetch_assoc($result)) {
       echo "Name: ".$my_contact['name'];
       echo "<br>\n";
       echo "Title: ".$title[$my_contact['title']];
       echo "<br><br>\n";
    }[/code]
    The title table also has a sort-by field -- which is what I want to sort the contacts results by. This would allow the "president" of a company to show up first, and his/her "assistant" to show up later on.

    I've been hacking on it for a few hours -- but I just can't figure out how to accomplish this without writing some kind of bubble sort. Any ideas would be greatly appreciated.

    Thanks!
    [/quote]


    You are going about this all wrong. Relational databases by their nature can join tables together. Remember that the result of a query is always a "result set" aka a table. Rather than using 2 seperate queries and trying to bind them together, you can simply join them in one query and use ORDER BY to order the result set in the way you want it to be.

    For example, experiment with phpMyAdmin and try something like:


    [code]
    SELECT contacts.*, titles.* FROM contacts, titles WHERE titles.title_id = contacts.contact_id ORDER BY title
    [/code]
×
×
  • 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.