Overview

Namespaces

  • None
  • Yajra
    • Oci8
      • Connectors
      • Eloquent
      • Query
        • Grammars
        • Processors
      • Schema
        • Grammars

Classes

  • Yajra\Oci8\Connectors\OracleConnector
  • Yajra\Oci8\Eloquent\OracleEloquent
  • Yajra\Oci8\Oci8Connection
  • Yajra\Oci8\Oci8ServiceProvider
  • Yajra\Oci8\Query\Grammars\OracleGrammar
  • Yajra\Oci8\Query\OracleBuilder
  • Yajra\Oci8\Query\Processors\OracleProcessor
  • Yajra\Oci8\Schema\Comment
  • Yajra\Oci8\Schema\Grammars\OracleGrammar
  • Yajra\Oci8\Schema\OracleAutoIncrementHelper
  • Yajra\Oci8\Schema\OracleBlueprint
  • Yajra\Oci8\Schema\OracleBuilder
  • Yajra\Oci8\Schema\Sequence
  • Yajra\Oci8\Schema\Trigger

Traits

  • Yajra\Oci8\OracleReservedWords

Functions

  • config_path
  • Overview
  • Namespace
  • Class
 1: <?php
 2: 
 3: namespace Yajra\Oci8\Schema;
 4: 
 5: use Illuminate\Database\Connection;
 6: 
 7: class Trigger
 8: {
 9:     /**
10:      * @var \Illuminate\Database\Connection
11:      */
12:     protected $connection;
13: 
14:     /**
15:      * @param Connection $connection
16:      */
17:     public function __construct(Connection $connection)
18:     {
19:         $this->connection = $connection;
20:     }
21: 
22:     /**
23:      * function to create auto increment trigger for a table
24:      *
25:      * @param  string $table
26:      * @param  string $column
27:      * @param  string $triggerName
28:      * @param  string $sequenceName
29:      * @return boolean
30:      */
31:     public function autoIncrement($table, $column, $triggerName, $sequenceName)
32:     {
33:         if (! $table or ! $column or ! $triggerName or ! $sequenceName) {
34:             return false;
35:         }
36: 
37:         return $this->connection->statement("
38:             create trigger $triggerName
39:             before insert on {$table}
40:             for each row
41:                 begin
42:             if :new.{$column} is null then
43:                 select {$sequenceName}.nextval into :new.{$column} from dual;
44:             end if;
45:             end;");
46:     }
47: 
48:     /**
49:      * function to safely drop trigger db object
50:      *
51:      * @param  string $name
52:      * @return boolean
53:      */
54:     public function drop($name)
55:     {
56:         if (! $name) {
57:             return false;
58:         }
59: 
60:         return $this->connection->statement("
61:             declare
62:                 e exception;
63:                 pragma exception_init(e,-4080);
64:             begin
65:                 execute immediate 'drop trigger {$name}';
66:             exception
67:             when e then
68:                 null;
69:             end;");
70:     }
71: }
72: 
API documentation generated by ApiGen