Fill the property tables in a well format for the process method.

@param TableInterface[] $tablesArray The validated tables array.

@throws \Exception Statements table method have to be invoked, otherwise the builder can not build a valid query.
483198
private function _prepareTables(array $tablesArray)
	{
		if(count($tablesArray) === 0)
		{
			throw new \Exception('"table"-method of the statement have to invoked before!');
		}

		$tables = ' ';
		foreach($tablesArray as $table)
		{
			$tables .= $table->getExpression() . ', ';
		}
		$tables       = substr($tables, 0, strlen($tables) - 2);
		$this->tables = $tables . ' ';
	}
632798
public function setFields( $fields )
	{
		if( is_array( $fields ) && count( $fields ) )
			$this->fields = $fields;
		else
			trigger_error( 'Field Array of Table Definition must no be empty.', E_USER_ERROR );
	}
1122593
public function check(Table $table)
    {
        $columns = $table->getColumns();
        foreach ($columns as $id => $params) {
            if (!isset($params['sql_id']))
                throw new \Exception("No 'sql_id' param for ID $id");
        }

        $backupSqlAnds = $this->sqlAnds;
        $backupSqlParams = $this->sqlParams;

        $successfulFilters = [];
        foreach ($table->getFilters() as $column => $filterData) {
            $successfulNames = [];
            foreach ($filterData as $name => $value) {
                if ($this->buildFilter($columns[$column]['sql_id'], $columns[$column]['type'], $name, $value))
                    $successfulNames[$name] = $value;
            }
            if (count($successfulNames) > 0)
                $successfulFilters[$column] = $successfulNames;
        }
        $table->setFilters($successfulFilters);

        $this->sqlAnds = $backupSqlAnds;
        $this->sqlParams = $backupSqlParams;
        return $this;
    }
824666
public function fill(array $attributes = [])
    {
        $this->raw = $attributes;

        $excludes = config("api.excludes");

        foreach ($attributes as $key => $attribute) {
            // Guarded attributes should be removed
            if (in_array($key, $excludes)) {
                unset($attributes[$key]);
            }
            else if (method_exists($this, $key) && ((is_array($attribute) || is_null($attribute)))) {
                // Its a relation
                $this->relationAttributes[$key] = $attribute;

                // For belongs to relation, while filling, we need to set relation key.
                $relation = call_user_func([$this, $key]);

                if ($relation instanceof BelongsTo) {
                    $primaryKey = $relation->getRelated()->getKeyName();

                    if ($attribute !== null) {
                        // If key value is not set in request, we create new object
                        if (!isset($attribute[$primaryKey])) {
                            throw new RelatedResourceNotFoundException('Resource for relation "' . $key . '" not found');
                        }
                        else {
                            $model = $relation->getRelated()->find($attribute[$primaryKey]);

                            if (!$model) {
                                // Resource not found
                                throw new ResourceNotFoundException();
                            }
                        }
                    }

                    $relationKey = $relation->getForeignKey();

                    $this->setAttribute($relationKey, ($attribute === null) ? null : $model->getKey());
                }

                unset($attributes[$key]);
            }
        }

        return parent::fill($attributes);
    }
416495
private function structureDatasArray($arrayDatas = [], $tableColumns = [])
    {
        foreach ($arrayDatas as $arrayData) {
            $datasArray[$arrayData['pros_id']] = [];

            foreach($tableColumns as $columnKey => $columnValue) {
                foreach ($arrayData as $dataKey => $dataValue) {
                    if ($columnValue == $dataKey) {
                        $datasArray[$arrayData['pros_id']] = $datasArray[$arrayData['pros_id']] + [$dataKey => $dataValue];
                        break;
                    }
                }
            }
        }

        return $datasArray;
    }
1339562
public function insert(array $options=array()) {
		$options += self::$insertDefaults;
		if( empty($options['table']) ) {
			throw new Exception('Empty table option');
		}
		if( empty($options['what']) ) {
			throw new Exception('No field');
		}
		$OPTIONS = '';
		$OPTIONS .= (!empty($options['lowpriority'])) ? ' LOW_PRIORITY' : (!empty($options['delayed'])) ? ' DELAYED' : '';
		$OPTIONS .= (!empty($options['ignore'])) ? ' IGNORE' : '';
		$OPTIONS .= (!empty($options['into'])) ? ' INTO' : '';
		
		$COLS = $WHAT = '';
		//Is an array
		if( is_array($options['what']) ) {
			//Is an indexed array of fields Arrays
			if( !empty($options['what'][0]) ) {
				// Quoted as escapeIdentifier()
				$COLS = '(`'.implode('`, `', array_keys($options['what'][0])).'`)';
				foreach($options['what'] as $row) {
					$WHAT .= (!empty($WHAT) ? ', ' : '').'('.implode(', ', $row).')';
				}
				$WHAT	= 'VALUES '.$WHAT;
			//Is associative fields Arrays
			} else {
// 				$WHAT	= 'SET '.parseFields($options['what'], '`');
				$WHAT	= 'SET '.$this->formatFieldList($options['what']);
			}
			
		//Is a string
		} else {
			$WHAT	= $options['what'];
		}
		$TABLE		= static::escapeIdentifier($options['table']);
		
		$QUERY = "INSERT {$OPTIONS} {$TABLE} {$COLS} {$WHAT}";
		if( $options['output'] == static::SQLQUERY ) {
			return $QUERY;
		}
		return $this->query($QUERY, PDOEXEC);
	}
1179402
private function _prepareLimit(array $limitArray)
	{
		if(count($limitArray) === 1)
		{
			foreach($limitArray as $begin => $amount)
			{
				$this->limit = 'LIMIT ' . $begin . ', ' . $amount . ' ';
			}
		}
	}
339819
public function setTableAttributes(array $attributes)
    {
        foreach ($attributes as $attribute => $value) {
            $this->tableAttributes[$attribute] = $value;
        }

        return $this;
    }
309313
private function _prepareJoinTable(array $tables)
	{
		$this->tables = ' ';
		foreach($tables as $tableObj)
		{
			$this->tables .= $tableObj->getExpression() . ', ';
		}
		$this->tables = rtrim(rtrim($this->tables), ',') . ' ';
	}
1327006
private function initFromArray(array $fieldArray = [])
    {
        foreach ($fieldArray as $fieldName => $fieldParams) {
            $this->addField($fieldName, Factory::get($fieldParams));
        }
    }
650514
public function columns(array $values, $width = 5, $tableStyle = 'compact', array $columnStyles = [])
    {
        $table = new Table($this);
        $table->setHeaders([])->setRows(iterator_to_array($this->chunk($values, $width)))->setStyle($tableStyle);

        foreach ($columnStyles as $columnIndex => $columnStyle) {
            $table->setColumnStyle($columnIndex, $columnStyle);
        }

        $columnWidths = $this->getColumnWidths($width);
        $table->setColumnWidths($columnWidths);

        $table->render();
    }
199576
protected function fillWithEmptyCells($table_row,$tag_row)
  {
    $html = '';

    if( ! ($table_row instanceof TableLine) )
    {
      throw new \InvalidArgumentException;
    }

    $length_row = $table_row->getLength();
    $diff = $this->max_length_rows - $length_row;

    if( $diff > 0 )
    {
      // add empty cells
      foreach( range(1,$diff) as $key)
      {
        $html.="\t\t\t<{$tag_row}></{$tag_row}>\n";
      }
    }

    $html.="\t\t</tr>\n";

    return $html;
  }
609513
public function setFields($table, $fields = array("*")){

		//put this in try...catch block for better error handling
		try{

			//check if from is empty
			if ( empty($table)) 
			{
				//throw new exception
				throw new MySQLException("Invalid argument passed for table name", 1);

			}

		}

		//diplay error message
		catch(MySQLException $MySQLExceptionObject){

			//display error message
			$MySQLExceptionObject->errorShow();

		}		

		//check if fields is sset and set the fields param
		$this->froms = $table;
		$this->fields[$table] = $fields;
	}
691405
public function setAttributes($attributes = [])
    {
        if (empty($attributes) || !is_array($attributes)) {
            throw new DatabaseException(sprintf('Invalid argument passed to %s', __FUNCTION__));
        }

        foreach ($attributes as $key => $value) {
            $this->__set($key, $value);
        }
    }
28059
public function copyToArray(array &$array)
    {
        parent::copyToArray($array);

        $array['action']                = LanguageUtility::toString($this->action);
        $array['responseContent']       = $this->responseContent;
        $array['username']              = $this->username;
        $array['password']              = $this->password;
        $array['ticket']                = $this->ticket;
        $array['accessToken']           = $this->accessToken;
        $array['accessTokenExpiresAt']  = LanguageUtility::orZero($this->accessTokenExpiresAt);
        $array['accessTokenDuration']   = LanguageUtility::orZero($this->accessTokenDuration);
        $array['refreshToken']          = $this->refreshToken;
        $array['refreshTokenExpiresAt'] = LanguageUtility::orZero($this->refreshTokenExpiresAt);
        $array['refreshTokenDuration']  = LanguageUtility::orZero($this->refreshTokenDuration);
        $array['idToken']               = $this->idToken;
        $array['grantType']             = LanguageUtility::toString($this->grantType);
        $array['clientId']              = $this->clientId;
        $array['clientIdAlias']         = $this->clientIdAlias;
        $array['clientIdAliasUsed']     = $this->clientIdAliasUsed;
        $array['subject']               = $this->subject;
        $array['scopes']                = $this->scopes;
        $array['properties']            = LanguageUtility::convertArrayOfArrayCopyableToArray($this->properties);
    }
402168
public function importFromArray($array)
    {
        if (!is_array($array)) {
            throw new \Exception('invalid array');
        }
        $reflect = new ReflectionClass(get_called_class());
        $properties = $reflect->getDefaultProperties();
        foreach ($properties as $key => $value) {
            if (array_key_exists($key, $array)) {
                $this->{$key} = $array[$key];
            }
        }
    }
1149113
public function copyToArray(array &$array)
    {
        parent::copyToArray($array);

        $array['action']               = LanguageUtility::toString($this->action);
        $array['service']              = LanguageUtility::convertArrayCopyableToArray($this->service);
        $array['client']               = LanguageUtility::convertArrayCopyableToArray($this->client);
        $array['clientIdAliasUsed']    = $this->clientIdAliasUsed;
        $array['display']              = LanguageUtility::toString($this->display);
        $array['maxAge']               = LanguageUtility::orZero($this->maxAge);
        $array['scopes']               = LanguageUtility::convertArrayOfArrayCopyableToArray($this->scopes);
        $array['uiLocales']            = $this->uiLocales;
        $array['claimsLocales']        = $this->claimsLocales;
        $array['claims']               = $this->claims;
        $array['acrEssential']         = $this->acrEssential;
        $array['acrs']                 = $this->acrs;
        $array['subject']              = $this->subject;
        $array['loginHint']            = $this->loginHint;
        $array['prompts']              = LanguageUtility::convertArrayToStringArray($this->prompts);
        $array['requestObjectPayload'] = $this->requestObjectPayload;
        $array['idTokenClaims']        = $this->idTokenClaims;
        $array['userInfoClaims']       = $this->userInfoClaims;
        $array['responseContent']      = $this->responseContent;
        $array['ticket']               = $this->ticket;
    }