Forum Replies Created

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter modparlor

    (@modparlor)

    No reply from Support after a week. Note: I’m a paying customer.

    I’ve further worked with Pie and Donut charts now. Same random color bug, although Pies & Donuts let me change colors, initial. One View-refresh in the editor however, and the colors are deleted and randomised again.

    My Setup: WP 5.2.2 (current stable), Mint installation, Firefox (current version), Ubuntu Server LTS 2018 LAMP Setup.

    Conclusion: I’d rate this product 2 stars after what I know now. Save yourself the money and trouble. I will programm my charts with ChartJS myself to avoid the unreliability of this. I would strongly advise against buying this product – save yourself the money and trouble. I’m sorry to have to conclude that.

    Thread Starter modparlor

    (@modparlor)

    Did you guys get my support request? I’m awaiting a reply.

    Thread Starter modparlor

    (@modparlor)

    Just did. Details are in the support request in which I refer to this thread.

    Thread Starter modparlor

    (@modparlor)

    How about assigning each colum in the CSV to a field in the DB and giving it consistant naming – LIKE THE ONE USED IN THE DB? … OK, so consistant won’t be possible, this is WordPress. But I think it’s not to much asked to do a proper assignment to DB fields and a line or two of explainations of those fields – that way your little script could easyly work relyably.

    Whatever you do, a file-import into a DB should never get mixed up simply because the fields are in a ‘wrong’ order and this isn’t even documented. … Maybe I’m wrong and the relevante DB fields have changed in 4.2.x (this was the version I used the plugin in) – but I doubt it.

    I’ve added a DB Import Class from a project of mine in this post as code below. Pay attention to the openFile(…) function and the >>>>first line is fieldnames<<<< comment, the getImportLine(…) function and the getAttributeList(…) function. This is definitely not the best DB import, but this is how it should be done. I appreciate your free plugin, but sorry dude, bad code is bad code.

    You may use this code whereever you may need it in this plugin. Hope to see an improved update soon. ;;-)

    <?php
    	class DbImport
    	{
    		private $importSourceIsFile = false;
    		private $importFile;
    		private $fileFieldNames;
    		private $fileFieldNameCount;
    
    		private $importResult;
    		private $entities = array(
    			"primaerdb_firma",
    			"primaerdb_adresse",
    // ... and so forth (array of relevant tables)
    // ... and so forth (array of relevant tables)
    // ... and so forth (array of relevant tables)
    // ... and so forth (array of relevant tables)
    // ... and so forth (array of relevant tables)
    			"primaerdb_homepages"
    		);
    		private $allAttribs = array();
    		private $entityIsActive = array();
    
    		private $ursprung;
    
    		private $dataErrorCount=0;
    		private $importCount=0;
    
    		public function __construct()
    		{
    			foreach ($this->entities as $entity)
    			{
    				$this->allAttribs[$entity] = $this->getAttributeList($entity);
    			}
    
    			foreach ($this->entities as $entity)
    			{
    				$this->entityIsActive[$entity] = false;
    			}
    			FB_select("SET NAMES 'utf8'");
    		}
    
    		public function doImport($isTest = false)
    		{
    			while($importLine = $this->getImportLine())
    			{
    				$obj_imp_adresse = new Import_adresse();
    				$importBranch = array();
    
    				foreach ($this->entities as $entity)
    				{
    					foreach($this->allAttribs[$entity] as $attribute)
    					{
    						if(isset($importLine[$entity."-".$attribute]))
    						{
    							$importBranch[$entity][$attribute] = $importLine[$entity."-".$attribute];
    							$this->entityIsActive[$entity] = true;
    						} else {
    							$importBranch[$entity][$attribute] = "";
    						}
    						if (
    							("primaerdb_firma" == $entity)
    							&&
    							("strUrsprung" == $attribute)
    						){
    							$importBranch[$entity][$attribute] = $this->ursprung;
    						}
    					}
    				}
    
    				if ($this->entityIsActive['primaerdb_firma'] && $this->entityIsActive['primaerdb_adresse'])
    				{
    					$this->importCount++;
    					// Firm
    					$obj_imp_adresse->insert_firma($importBranch['primaerdb_firma']);
    
    					// Address
    					$obj_imp_adresse->insert_adresse($importBranch['primaerdb_adresse']);
    
    					// Partner
    					if ($this->entityIsActive['primaerdb_ansprechpartner'])
    					{
    						$obj_imp_adresse->insert_ansprechpartner($importBranch['primaerdb_ansprechpartner']);
    					}
    
    					// Kontakt
    					if ($this->entityIsActive['primaerdb_kontakt'])
    					{
    						$obj_imp_adresse->insert_kontakt($importBranch['primaerdb_kontakt']);
    					}
    
    					// Industry
    					if ($this->entityIsActive['primaerdb_branche'])
    					{
    						$obj_imp_adresse->insert_branche($importBranch['primaerdb_branche']);
    					}
    
    					//.... and so forth ....
    					//.... and so forth ....
    					//.... and so forth ....
    				}
    				unset($obj_imp_adresse);
    			}
    
    			$out = "";
    			$out .= "\nAmount of imported datasets: ".$this->importCount;
    			$out .= "\nAmount of datasets *not* imported: ".$this->dataErrorCount."\n";
    			return $out;
    		}
    		public function openFile($filename)
    		{
    			$this->importFile = fopen($filename ,"r");
    
    			#Erste Zeile sind Feldnamen (>>>>first line is fieldnames<<<<):
    			$getLine = fgets($this->importFile);
    
    			//Whitespace removal special for corrupted data
    			$fNames = explode(";", $getLine);
    			foreach($fNames as $fName)
    			{
    				$this->fileFieldNames[] = trim($fName);
    			}
    
    			$this->fileFieldNameCount = count($this->fileFieldNames);
    
    			$this->ursprung = "Datei: $filename";
    			$this->importSourceIsFile = true;
    		}
    		public function openTable($tableName)
    		{
    			$host = "db.mydomain.com";
    			$db = "firmen_db_csv_import";
    			# Import Host definieren, importResult holen:
    			$DB_HOSTS=Array(new dbHost($host, $db,"admin","PASSWORD"));
    			$this->importResult = FB_select("SELECT * FROM $tableName");
    
    			$this->ursprung = "Host: $host, DB: $db, Tabelle: $tableName";
    			$this->importSourceIsFile = false;
    		}
    		private function getImportLine()
    		{
    			if($this->importSourceIsFile)
    			{
    				$lineArray = array();
    				$thisLine = $this->getValidFileLine();
    
    				for($i = 0; $i < $this->fileFieldNameCount; $i++)
    				{
    					$lineArray[$this->fileFieldNames[$i]] = $thisLine[$i];
    				}
    				return $lineArray;
    			} else {
    				return mysql_fetch_assoc($this->importResult);
    			}
    		}
    		private function getValidFileLine()
    		{
    			$getLine = fgets($this->importFile);
    			$rLine = explode(";", $getLine);
    
    			if(count($rLine) != $this->fileFieldNameCount)
    			{
    				$rLine = $this->getValidFileLine();
    				$this->dataErrorCount++;
    			}
    			return $rLine;
    		}
    		private function getAttributeList($entity)
    		{
    			$sql = "SHOW COLUMNS FROM $entity";
    			$result = FB_select($sql);
    			$rM = array();
    			while($attrib = mysql_fetch_assoc($result))
    			{
    				if(
    					(false === strpos($attrib['Field'], "_id"))
    					&&
    					(false === strpos($attrib['Field'], "dTimestamp"))
    				){
    					$rM[] = $attrib['Field'];
    				}
    			}
    			return $rM;
    		}
    	}
    ?>

Viewing 4 replies - 1 through 4 (of 4 total)