Exemple #1
0
 /**
  * Execute the blueprint against the database.
  *
  * @param  \Illuminate\Database\Connection  $connection
  * @param  \Illuminate\Database\Schema\Grammars\Grammar $grammar
  * @return void
  */
 public virtual void build(Connection connection, SchemaGrammar grammar)
 {
     foreach (var statement in this.toSql(connection, grammar))
     {
         connection.statement(statement);
     }
 }
Exemple #2
0
        /**
         * Get the raw SQL statements for the blueprint.
         *
         * @param  \Illuminate\Database\Connection  $connection
         * @param  \Illuminate\Database\Schema\Grammars\Grammar  $grammar
         * @return array
         */
        public virtual string[] toSql(Connection connection, SchemaGrammar grammar)
        {
            this.addImpliedCommands();
            var statements = new string[0];

            // Each type of command has a corresponding compiler BlueprintColumn on the schema
            // grammar which is used to build the necessary SQL statements to build
            // the blueprint element, so we'll just call that compilers function.
            foreach (var command in this._commands)
            {
                var method = "compile" + StrUtil.ucfirst(command.name);
                if (ReflectionUtil.existsMethod(this.GetType(), method))
                {
                    string[] sql = (string[])ReflectionUtil.callMethod(grammar, method, this, command, connection);
                    statements = ArrayUtil.push(statements, sql);
                }
            }
            return(statements);
        }
Exemple #3
0
 /**
  * Create a new database Schema manager.
  *
  * @param  \Illuminate\Database\Connection  $connection
  * @return void
  */
 public Builder(Connection connection)
 {
     this._connection = connection;
     this._grammar    = connection.getSchemaGrammar();
 }
Exemple #4
0
 /**
  * Set the schema grammar used by the connection.
  *
  * @param  \Illuminate\Database\Schema\Grammars\Grammar  $grammar
  * @return void
  */
 public virtual void setSchemaGrammar(SchemaGrammar grammar)
 {
     this._schemaGrammar = grammar;
 }
Exemple #5
0
 /**
  * Set the schema grammar to the default implementation.
  *
  * @return void
  */
 public virtual void useDefaultSchemaGrammar()
 {
     this._schemaGrammar = this.getDefaultSchemaGrammar();
 }