Resource Model

sqlBlock Test Page

This page shows tests of the sqlBlock Object (View Source). NOTE, this public test prints out the SQL produced from the statement. I decided not to put the page that tests the execution of this SQL on this page.

Test INSERT

This is the test of an INSERT statement:

INSERT INTO Test_Table (one, two, three, four) VALUES ('1', '2', 'Third Item', 'Fourth Item')

Test REPLACE

This is the test of a REPLACE statement:

REPLACE INTO Test_Table (one, two, three, four) VALUES ('1', '2', 'Third Item', 'Fourth Item')

Test UPDATE

This is the test of a UPDATE statement:

Statement: UPDATE Test_Table SET three='Third Item', four='Fourth Item', five='Fifth Column' WHERE one='1' and two='2'

Test Required

This is the test of the required constraint. The test creates the SQL with a missing piece of data. There should be an error preventing its execution.

Statement: UPDATE Test_Table SET three='Third Item', four='Fourth Item' WHERE one='1' and two=''

This var_dump() shows the data from the object
object(sqlBlock)#5 (10) {
  ["db":"sqlBlock":private]=>
  string(4) "main"
  ["table":"sqlBlock":private]=>
  string(10) "Test_Table"
  ["command":"sqlBlock":private]=>
  string(1) "u"
  ["sqlStr":"sqlBlock":private]=>
  string(24) "three=:three, four=:four"
  ["valStr":"sqlBlock":private]=>
  NULL
  ["whereStr":"sqlBlock":private]=>
  string(28) " WHERE one=:one and two=:two"
  ["limit":"sqlBlock":private]=>
  NULL
  ["colCnt":"sqlBlock":private]=>
  int(0)
  ["dataArr":"sqlBlock":private]=>
  array(4) {
    ["one"]=>
    int(1)
    ["two"]=>
    string(0) ""
    ["three"]=>
    string(10) "Third Item"
    ["four"]=>
    string(11) "Fourth Item"
  }
  ["actions":"sqlBlock":private]=>
  array(4) {
    ["i"]=>
    string(12) "INSERT INTO "
    ["u"]=>
    string(7) "UPDATE "
    ["d"]=>
    string(12) "DELETE FROM "
    ["r"]=>
    string(13) "REPLACE INTO "
  }
}