Jump to content

ballhogjoni

Members
  • Posts

    1,026
  • Joined

  • Last visited

Everything posted by ballhogjoni

  1. So i've always struggled with coding reports that have a lot of logic and calculations because the become very procedural and they become hard to debug and hard to add new features/calculations. What do you guys do when coding reports to make them easy to maintain and add new features?
  2. 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;
  3. Hey guys, not sure if this is the correct place for this topic, but I was wondering why you would use overloading? I just haven't ever come across a need for it and if I have I haven't recognized it.
  4. Using PHP 5.3.3 The error points out this line of code: return [$a[$s], "string"]; $a = array(); $s = "test"; if (array_key_exists($s, $a)) return [$a[$s], "string"]; What's wrong with this code?
  5. 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 ***
  6. 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.
  7. So i thought it could be that I was running out of physical memory. I am running macbook with 8gb physical memory. With everything running, chrome, spotify, etc it was taking about 7.5gb of memory. I shutdown everything and it still didn't work.
  8. That's what I thought as well, but I don't get any errors and I set ini_set('memory_limit', '1024M'); So to double check the memory usage I ran memory_get_usage() and it was sitting at 585728
  9. 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"); }
  10. Had to install this rpm ftp://195.220.108.108/linux/remi/enterprise/6/remi/x86_64/php-soap-5.4.27-1.el6.remi.x86_64.rpm by running this on the command line rpm -ivv ftp://195.220.108.108/linux/remi/enterprise/6/remi/x86_64/php-soap-5.4.27-1.el6.remi.x86_64.rpm then restarted apache.
  11. 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
  12. I was using the array shorthand code "[]" but didn't realize my box was using php 5.3. I just upgrade to 5.4 and the script works now. I was expecting to get some error relating to the array shorthand code not being valid, maybe a syntax error.
  13. 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.
  14. Ok so it looks like it was working the whole time. When I preview the csv in open office it shows the correct data, but when I open it the comma's are gone. My guess is it's a bug in open office.
  15. 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
  16. ok didn't think you'd need more code because i thought it had something to do with fputcsv Here's a sample var_dump of data array{ ... [28]=> string(9) "1869,1821" [29]=> string(1) "N" [30]=> int(3) [31]=> string(1) "1" [32]=> string(1) "1" [33]=> string(7) "171,172"} that var dump is printed the line above fputcsv($output, $data);
  17. 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
  18. Can somebody tell me what this character(s) is "^@" I am getting this string from Amazon api for orders that have been placed on my sellers account: ^@Steven Lastname^@
  19. I've searched google with no luck. I'm wondering if there's a way to follow the full processlist in mysql from the command line. I'm looking for something like the tail command.
  20. 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.
  21. 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.
  22. I'm trying to match SKU: DD-969991 and get DD-969991 out of matches. if (preg_match('/SKU:\s(\w+)/', $content, $matches)) { $sku = $matches[1]; } with this I get DD. I need the whole string DD-969991
  23. 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.