protected function primeQuery($statementString, array $parameters) {
	
		$statement = $this->connection->prepare($statementString);
	
		foreach($parameters as $name => $value) {
	
			// question mark placeholders start with 1
	
			if(is_int($name)) {
				++$name;
			}
	
			// otherwise ensure colons
	
			else {
				$name = ':' . ltrim($name, ':');
			}
	
			// set parameter types, depending on parameter values
	
			$type = \PDO::PARAM_STR;

			if(is_bool($value)) {
				$type = \PDO::PARAM_BOOL;
			}
	
			else if(is_int($value)) {
				$type = \PDO::PARAM_INT;
			}
	
			else if(is_null($value)) {
				$type = \PDO::PARAM_NULL;
			}

			else if($value instanceof \DateTime) {
			    $value = $value->format('Y-m-d H:i:s');
            }

			else if(is_object($value)) {
                if(method_exists($value, '__toString')) {
                    $value = (string) $value;
                }
                else {
                    throw new \InvalidArgumentException('Value cannot be converted into string.');
                }
            }

			$statement->bindValue($name, $value, $type);

		}

        $this->statement = $statement;
        return $statement;

    }
protected function primeQuery($statementString, array $parameters) {
	
		$statement = $this->connection->prepare($statementString);
	
		foreach($parameters as $name => $value) {
	
			// question mark placeholders start with 1
	
			if(is_int($name)) {
				++$name;
			}
	
			// otherwise ensure colons
	
			else {
				$name = ':' . ltrim($name, ':');
			}
	
			// set parameter types, depending on parameter values
	
			$type = \PDO::PARAM_STR;

			if(is_bool($value)) {
				$type = \PDO::PARAM_BOOL;
			}
	
			else if(is_int($value)) {
				$type = \PDO::PARAM_INT;
			}
	
			else if(is_null($value)) {
				$type = \PDO::PARAM_NULL;
			}

			else if($value instanceof \DateTime) {
			    $value = $value->format('Y-m-d H:i:s');
            }

			else if(is_object($value)) {
                if(method_exists($value, '__toString')) {
                    $value = (string) $value;
                }
                else {
                    throw new \InvalidArgumentException('Value cannot be converted into string.');
                }
            }

			$statement->bindValue($name, $value, $type);

		}

        $this->statement = $statement;
        return $statement;

    }
protected function primeQuery ( $ statementString , array $ parameters ) { $ statement = $ this -> connection -> prepare ( $ statementString ) ; foreach ( $ parameters as $ name => $ value ) { // question mark placeholders start with 1 if ( is_int ( $ name ) ) { ++ $ name ; } // otherwise ensure colons else { $ name = ':' . ltrim ( $ name , ':' ) ; } // set parameter types, depending on parameter values $ type = \ PDO :: PARAM_STR ; if ( is_bool ( $ value ) ) { $ type = \ PDO :: PARAM_BOOL ; } else if ( is_int ( $ value ) ) { $ type = \ PDO :: PARAM_INT ; } else if ( is_null ( $ value ) ) { $ type = \ PDO :: PARAM_NULL ; } else if ( $ value instanceof \ DateTime ) { $ value = $ value -> format ( 'Y-m-d H:i:s' ) ; } else if ( is_object ( $ value ) ) { if ( method_exists ( $ value , '__toString' ) ) { $ value = ( string ) $ value ; } else { throw new \ InvalidArgumentException ( 'Value cannot be converted into string.' ) ; } } $ statement -> bindValue ( $ name , $ value , $ type ) ; } $ this -> statement = $ statement ; return $ statement ; }
prepare a statement and bind parameters

@param string $statementString
@param array $parameters

@return \PDOStatement
prepare a statement and bind parameters