Results 1 to 3 of 3
  1. #1

    Default please help Php, mySQL n Perl dami kung assignment dko kaya lahat


    PHP
    5. Using the function declaration below, explain whether or not the function has any errors in it, what its purpose is and any optimizations you think can be made. Be sure to include descriptions of the passed arguments and function output, if any. Be sure to state your assumptions.

    1 function get_employees_by_hierarchy( $_employee_id = 0,$_depth = 0,$_org_array = array() ) {
    2 if ( $this->org_depth < $_depth ) {
    3 $this->org_depth = $_depth;
    4 }
    5 $_depth++;
    6 $_query = "SELECT * FROM employees WHERE ";
    7 if ( !$_employee_id ) {
    8 $_query .= "employee_manager_id IS NULL OR employee_manager_id = 0";
    9 }
    10 else {
    11 $_query .= "employee_manager_id = " . $this->dbh->quoteSmart( $_employee_id );
    12 }
    13 $_result = $this->query( $_query );
    14
    15 while ( $_row = $_result->fetchRow() ) {
    16 $_row['depth'] = $_depth;
    17 array_push( $_org_array, $_row );
    18 $_org_array = $this->get_employees_by_hierarchy(
    19 $_row['employee_manager_id'],
    20 $_depth,
    21 $_org_array
    22 );
    23 }
    24 return $_org_array;
    25 }

    Follow Up Questions:
    5. Speculate why lines 2 – 4 are necessary.
    6. Speculate why line 16 is necessary.

    MYSQL
    Given the table structure and row data below, answer the follow up questions.
    mysql> explain user_skill;
    +--------------------------+------------------+------+-----+---------+----------------+
    | Field | Type | Null | Key | Default | Extra |
    +--------------------------+------------------+------+-----+---------+----------------+
    | user_skill_id | int(11) | | PRI | NULL | auto_increment |
    | user_skill_last_modified | timestamp(14) | YES | | NULL | |
    | user_skill_date_created | datetime | YES | | NULL | |
    | user_id | int(11) | YES | | NULL | |
    | skill_name | char(255) | YES | | NULL | |
    | skill_level | char(255) | YES | | NULL | |
    | skill_usage | char(255) | YES | | NULL | |
    | skill_last_used | char(255) | YES | | NULL | |
    | user_skill_endorsed | tinyint(1) | YES | | 0 | |
    +--------------------------+------------------+------+-----+---------+----------------+
    9 rows in set (0.00 sec)

    mysql> *************
    +--------------------+-------------------+--------------------+
    | user_firstname | user_lastname | skill_name |
    +--------------------+-------------------+--------------------+
    | Kim | Simpson | PHP |
    | Kim | Simpson | Perl |
    | Kim | Simpson | Microsoft Word |
    | Kim | Simpson | Microsoft Access |
    | Kim | Simpson | Accounting/Billing |
    | Kim | Simpson | Java |
    | Kim | Simpson | SQL |
    | Kim | Simpson | CSS |
    | Kim | Simpson | OO Programming |
    | Kim | Simpson | Microsoft Excel |
    +--------------------+-------------------+--------------------+
    10 rows in set (0.00 sec)


    Follow Up Questions:
    1. Assuming that the data stored in skill_name in the user_skill table might be repeated for different users, what changes would you make to the database to normalize the skill_name and reduce repeated storage? Show the structure of the new table(s).
    2. Recreate the query that returned the 10 rows of data supplied. Speculate on tables that would be needed that are not shown here.


    2. Given the following query, how could it be optimized? List all assumptions:

    select c.* FROM companies AS c JOIN users AS u USING(companyid) JOIN jobs AS j USING(userid) JOIN useraccounts AS ua USING(userid) WHERE j.jobid = 123;




    3. Answer the follow up questions based on the below:

    explain SELECT * FROM job JOIN job_postings ON (job.jobid = job_postings.jobid) JOIN companies ON companies.companyid = job.companyid WHERE job.jobid IN (16189,1618;
    +--------------+-------+-------------------+---------+---------+-------+------+-------------+
    | table | type | possible_keys | key | key_len | ref | rows | Extra |
    +--------------+-------+-------------------+---------+---------+-------+------+-------------+
    | job | const | PRIMARY,companyid | PRIMARY | 4 | const | 2 | |
    | companies | const | PRIMARY | PRIMARY | 4 | const | 2 | |
    | job_postings | ref | PRIMARY | PRIMARY | 4 | const | 8 | Using where |
    +--------------+-------+-------------------+---------+---------+-------+------+-------------+
    3 rows in set (0.00 sec)

    Follow Up Questions
    Explain any optimizations that can be made to the above query.
    How many rows will be analyzed by this query?

    JavaScript
    Given the JavaScript below, answer the follow up questions.

    1 spell_img = new Image();
    2 spell_img.src = '/images/standard/spellcheck.gif';
    3 spell_img.setAttribute('title',_lang_spellcheck );

    function find_text_boxes()
    {
    myforms = document.forms;
    for( i=0;i < myforms.length; i++ )
    {
    textareas = myforms[i].getElementsById('textarea');
    for( y=0; y < textareas.length; y++ )
    {
    spelllink = document.createElement('a');
    spelllink.setAttribute('href',"javascript:spellChe ck(" + i + ", '" + textareas[y].name + "')");
    spelllink.appendChild( spell_img.cloneNode(true) );
    textareaParent = textareas[y].parentNode;
    textareaParent.insertBefore( spelllink, textareas[y].nextSibling );
    }
    }
    }

    Follow Up Questions:
    1. Do any errors exist? If so, how would you fix them?
    2. How many images will this create and where will it place them?



    Perl
    3. Given the following piece of code, answer the follow up questions.

    1 foreach('country','city','state','desiredsalary', 'education')
    2 {
    3 my $loopname = $_;
    4 my $global = 'D_USER'.uc($_);
    5 my $hashname = 'System:_USER'.uc($_);
    6 foreach(
    7 sort
    8 {
    9 if ($loopname =~ /education|desiredsalary/i )
    10 {
    11 return($a <=> $b);
    12 }
    13 else
    14 {
    15 return ($$hashname{$a} cmp $$hashname{$b});
    16 }
    17 }
    18 keys(%{$hashname}) )
    19 {
    20 if ($$hashname{$_})
    21 {
    22 my %row={'name'=>$System::{$global}{$_},'value'=>$_};
    23 $template->addlooprow($global,%row);
    24 }
    25 }
    26 }


    Follow Up Questions
    1. Do any errors exist? If so, how would you fix them?
    2. Based on which conditions will the keys of $hashname be sorted?


    Please your answer kung kinsa tong nay answer send sako email: datukaboskungpalad@yahoo.com pass nako ugma hapon salamat sa tanan

  2. #2

    Default Re: please help Php, mySQL n Perl dami kung assignment dko kaya lahat

    Dude, we are more than willing to lend programming assistance to those who seek for help. We were, after all, newbies once. But please make an effort on your part.

    If you need quality answers, provide us with quality questions. No homework questions please.

    [ simon.cpu ]

  3. #3

    Default Re: please help Php, mySQL n Perl dami kung assignment dko kaya lahat

    thanks anyway dude.But praise God, I answered it all.Actually it was a Technical Exam to be made at home. But I got it somehow. I just try sharing this questions to those pipz dat r familiar with d language and since ds s not a quality question dat was provided by the across country company. But it was very challenging when you realized it and got it the right answers.

  4.    Advertisement

Similar Threads

 
  1. Need PHP help: nested MySQL table
    By bakakon in forum Programming
    Replies: 4
    Last Post: 02-09-2013, 12:31 AM
  2. MySQL Query Please Help
    By huskyfritz in forum Programming
    Replies: 4
    Last Post: 11-18-2011, 05:38 AM
  3. help with mySQL please...
    By aridoasis in forum Websites & Multimedia
    Replies: 2
    Last Post: 10-12-2007, 05:15 PM
  4. help with mySQL please... updated
    By aridoasis in forum Programming
    Replies: 3
    Last Post: 10-11-2007, 06:02 PM
  5. PHP Gurus please help...
    By rusbel in forum Programming
    Replies: 6
    Last Post: 08-04-2007, 08:48 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
about us
We are the first Cebu Online Media.

iSTORYA.NET is Cebu's Biggest, Southern Philippines' Most Active, and the Philippines' Strongest Online Community!
follow us
#top