Jump to content

ballhogjoni

Members
  • Posts

    1,026
  • Joined

  • Last visited

Posts posted by ballhogjoni

  1. On 12/4/2020 at 4:43 PM, requinix said:

    Overloading as in multiple methods with the same name but different signatures (argument lists)? Checking because we're mostly PHP here and PHP does not have overloading.

    Hey @requinix, thanks for the reply. According to the docs you have property and function overloading...see docs. For me I don't see the need to do something like this property overloading:

    class A {
    	$x = 123;
    }
    
    $var = new A();
    $var->abc = 456;

     

  2. I just installed mysql 5.1.73 on centos 6.7 and I get this error literally every time I hit enter. I've tried max_allowed_packet=500M and wait_timeout=28000 and restarting the server with neither helping. 

    mysql> show databases;
    ERROR 2006 (HY000): MySQL server has gone away
    No connection. Trying to reconnect...
    Connection id:    1
    Current database: *** NONE ***
    
  3. edit; after looking at your program logic, i'm going to guess that at some point your getProductRow() function just starts returning a false/empty array every time and the code ends up executing the continue; statement every time and is looping over the rest of the input file and not writing anything to the output.

     

    Thanks! This got me thinking and i went digging into code that was working for everything except for this one case that I wasn't handling. It was causing an infinite loop. I fixed that code and now all is good.

  4. I'm trying to write a new csv file using the data from a large 1.4gb csv file. The problem is that its not working with the code I have below. It just hangs up when the size of output (tempfile) reaches 848661. Any ideas?

    $file = "file.csv";
        $file_number = 1;
        if (!$output = fopen($tempfile, 'w')) {
            unlink($tempfile);
            die('could not open temporary output file');
        }
    
        $in_data = array();
        $header = true;
        $row = 0;
        while (($data = fgetcsv($handle, 0, $delimiter)) !== FALSE) {
            if ($header) {
                $in_data[] = $headers;
                fputcsv($output, $headers, "\t");
                $header = false;
                continue;
            }
    /*
                    if ( ($row % 10) == 0 ){
    error_log("sleeping on row: $row");
                        sleep(3);
                    }
    error_log("checking row: $row");
    */
                    if (!$val = getProductRow($data)) //this returns an array
                        continue;
    
                    $stat = fstat($output);
    error_log("Stat is: " . print_r($stat['size'],true));
                    if($stat['size'] > 9437184){
    error_log("saving the $file");
                        fputcsv($output, $val, "\t");
    error_log(__LINE__);
                        fclose($output);
    error_log(__LINE__);
                        if (file_exists($file))
                            unlink($file);
    error_log(__LINE__);
                        rename($tempfile, $file);
    error_log(__LINE__);
                        chmod($file, 0777);
    error_log(__LINE__);
                        $final_file_name = $file = "file$file_number.csv";
    error_log(__LINE__);
                        $tempfile = tempnam(".", "tmp"); // produce a temporary file name, in the current directory
    error_log("creating the $file");
                        if (!$output = fopen($tempfile, 'w')) {
    error_log(__LINE__);
                            unlink($tempfile);
                            die('could not open temporary output file');
                        }
    error_log(__LINE__);
                        fputcsv($output, $headers, "\t");
    error_log(__LINE__);
                        $file_number++;
    error_log(__LINE__);
                        continue;
                    }
    
    error_log(__LINE__);
                    fputcsv($output, $val, "\t");
                }
    
  5. I am running PHP 5.4.27 and I'm running into this error. I tried to install php-soap via yum install php-soap but i got this error

    Error: Package: php-soap-5.3.3-27.el6_5.x86_64 (updates)
               Requires: php-common(x86-64) = 5.3.3-27.el6_5
               Installed: php-common-5.4.27-1.el6.remi.x86_64 (@remi)
                   php-common(x86-64) = 5.4.27-1.el6.remi
               Available: php-common-5.3.3-26.el6.x86_64 (base)
                   php-common(x86-64) = 5.3.3-26.el6
               Available: php-common-5.3.3-27.el6_5.x86_64 (updates)
                   php-common(x86-64) = 5.3.3-27.el6_5
     You could try using --skip-broken to work around the problem
     You could try running: rpm -Va --nofiles --nodigest
    

    I think its because yum is trying to install an incompatible version of php-soap. Any ideas? Thanks

  6. I'm trying to output errors to my log but it's not working. My apache config is as follows:

    <VirtualHost *:80>
         ServerName domain.com
         ServerAlias www.domain.us
         DocumentRoot /var/www/html/domain
         <Directory /var/www/html/domain>
             Options +Indexes +FollowSymLinks +ExecCGI
             DirectoryIndex index.php
             AllowOverride All
             Order allow,deny
             Allow from all
         </Directory>
        ErrorLog /var/log/domain_error_log
    </VirtualHost>
    

    At the top of my script I have:

    error_reporting(E_ALL);
    ini_set('display_errors', 1);
    

    I don't want errors on globally so my php.ini errors is set to off. When I go to the script in the browser I get a blank screen with no output to /var/log/domain_error_log. I feel I am missing something but don't know what it is.

  7. Just wondering what everyones opinion is. If you are creating unit tests and running code coverage do you need a try catch block? It seems like unnecessary code to me and creates an unnecessary processing cost.

     

    Before you say something like "what about the times your code fails for unknown reasons?", from my experience the times your code fails for unknown reasons it's usually not a bug in your code but a connection problem to a db or missing data or something. For those types of problems you should have other checks in place, right?

     

    Am I way out on a limb here or do you guys concur?

     

    Just trying to improve my programming knowledge.

     

    Thanks

  8. So I am writing an array of data to $output via fputcsv but for some reason fputcsv it's stripping out the comma in this comma separated string "170,171".

     

    $output is the file being written to

    $data is an array of data

     

    The last element in $data is "170,171" when I open the csv file the string looks like "170171". What is weird and I don't understand is that 3 elements before this also has a comma separated string that looks similiar, "1800,1897,1987". Why is fputcsv($output, $data); stripping out the comma out of the last element and not any of the other elements?

     

    I realize that fputcsv($output, $headers); is using the comma as the default delimiter. I tried using fputcsv($output, $headers, "\t"); but it still didn't work.

     

    Thanks

  9. do you work on a local machine or a virtual machine hosted externally? My company does the external thing and I can't stand it. Other devs have access to it and can screw up your changes. Local is best because you are the only one access unless you explicitly give others access.

  10. Thanks for the feedback. Is there a way to find DD-239dsk-2348 and D-4ida-8aa-3ja? Basically the hyphens can be anywhere in the string. They aren't always in the same location. And there can be more than one.

  11. So I have an instance of UserXyzPersister which extends DBPersisterAbstract which extends DBPersisterBase.

     

    There is a function in the DBPersisterBase class that is protected:

    protected function getArray($arg){
    ...
    }
    

    I'm trying to access it via:

    $u = new UserXyzPersister();
    $u->getArray($arg);
    

    This is working. My question is, can only the children of DBPersisterBase access getArray() or can the parents as well?

×
×
  • 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.