Long run script increasing resources while executing - Page 2
Page 2 of 2 FirstFirst 12
Results 16 to 21 of 21

Thread: Long run script increasing resources while executing

  1. #16
    Member
    Join Date
    Oct 2016
    Posts
    61
    Quote Originally Posted by Derokorian View Post
    Why not just $spec_array[] = $row_specs; ?? Why do you need to separately assign each piece?
    Quote Originally Posted by dalecosp View Post
    That's a good point, assuming you don't have any extraneous info in $row_specs (and if he took our advice and didn't ask for any extra fields, that should be true), and you don't want to change any names (it appears he doesn't). Good catch
    It was working in it's previous form derokorian but I could tell what Mr. Packet wanted from me and hate to disappoint

  2. #17
    Pedantic Curmudgeon Weedpacket's Avatar
    Join Date
    Aug 2002
    Location
    General Contact Unit "Coping Mechanism"
    Posts
    22,489
    Quote Originally Posted by dalecosp View Post
    As far as my apps go, a lot of times I'm working with some "redonkulous" names and I want something shorter for my array:

    PHP Code:
    $c 0;
    while (
    $row_specs mysqli_fetch_assoc ($r_specs)) {
          
    $spec_array[$c]['name']  = $row_specs['really_long_name'];
          
    $spec_array[$c]['value'] = $row_specs['a_specific_value'];
          
    $c++;

    I guess I don't think much of the DB design choices/naming conventions made by some people in the past ...
    Howsabout
    PHP Code:
    while ($row_specs mysqli_fetch_assoc ($r_specs)) {
          
    $spec_array[] = [
                
    'name'  => $row_specs['really_long_name'],
                
    'value' => $row_specs['a_specific_value'],
          ];

    Or of course alias the columns in the original query, if you can get at that.
    THERE IS AS YET INSUFFICIENT DATA FOR A MEANINGFUL ANSWER
    FAQs! FAQs! FAQs! Most forums have them!
    Search - Debugging 101 - Collected Solutions - General Guidelines - Getting help at all

  3. #18
    Settled 4 red convertible dalecosp's Avatar
    Join Date
    Jul 2002
    Location
    Accelerating Windows at 9.81 m/s....
    Posts
    8,483
    Quote Originally Posted by Weedpacket View Post
    Howsabout
    PHP Code:
    while ($row_specs mysqli_fetch_assoc ($r_specs)) {
          
    $spec_array[] = [
                
    'name'  => $row_specs['really_long_name'],
                
    'value' => $row_specs['a_specific_value'],
          ];

    Or of course alias the columns in the original query, if you can get at that.
    I've used aliases. The bracket syntax is not supported on some of our systems, STILL.
    /!!\ mysql_ is deprecated --- don't use it! Tell your hosting company you will switch if they don't upgrade! /!!!\ ereg() is deprecated --- don't use it!

    dalecosp "God doesn't play dice." --- Einstein "Perl is hardly a paragon of beautiful syntax." --- Weedpacket

    Getting Help at All --- Collected Solutions to Common Problems --- Debugging 101 --- Unanswered Posts --- OMBE: Office Machines, Business Equipment

  4. #19
    Member
    Join Date
    Oct 2016
    Posts
    61
    Quote Originally Posted by Weedpacket View Post
    Or of course alias the columns in the original query, if you can get at that.
    Would you mind showing an example of something like this? It's been very enlightening to see the different and sleeker methods of creating these variables.

  5. #20
    Senior Member Derokorian's Avatar
    Join Date
    Apr 2011
    Location
    Denver
    Posts
    2,261
    Check this tutorial out.
    Sadly, nobody codes for anyone on this forum. People taste your dishes and tell you what is missing, but they don't cook for you. ~anoopmail
    I'd rather be a comma, then a full stop.
    User Authentication in PHP with MySQLi - Don't forget to mark threads resolved - MySQL(i) warning

  6. #21
    Settled 4 red convertible dalecosp's Avatar
    Join Date
    Jul 2002
    Location
    Accelerating Windows at 9.81 m/s....
    Posts
    8,483
    Quote Originally Posted by schwim2 View Post
    Would you mind showing an example of something like this? It's been very enlightening to see the different and sleeker methods of creating these variables.
    This isn't difficult. You alias SQL columns with the "AS" keyword:

    Code:
    #Original:
    SELECT USER, EMAIL_ADDRESS, RIDICULOUSLY_LONG_COLUMN_NAME from myTable;
    
    +----------+--------------------+--------------------------------------------+
    | USER     | EMAIL_ADDRESS      |  RIDICULOUSLY_LONG_COLUMN_NAME             | 
    | Bob      | bob@gmail.com      |      foobar                                |
    +----------+--------------------+--------------------------------------------+
    
    #with aliasing
    SELECT USER, EMAIL_ADDRESS as EMAIL, RIDICULOUSLY_LONG_COLUMN_NAME as FOO from myTable;
    +----------+--------------------+--------------------------------------------+
    | USER     | EMAIL              |  FOO                                       | 
    | Bob      | bob@gmail.com      |      foobar                                |
    +----------+--------------------+--------------------------------------------+
    So, your SQL server is returning different column names if you alias with the "AS" keyword.
    Last edited by dalecosp; 03-03-2017 at 12:49 PM.
    /!!\ mysql_ is deprecated --- don't use it! Tell your hosting company you will switch if they don't upgrade! /!!!\ ereg() is deprecated --- don't use it!

    dalecosp "God doesn't play dice." --- Einstein "Perl is hardly a paragon of beautiful syntax." --- Weedpacket

    Getting Help at All --- Collected Solutions to Common Problems --- Debugging 101 --- Unanswered Posts --- OMBE: Office Machines, Business Equipment

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •