Example #1
0
 public function vardefProvider()
 {
     $GLOBALS['log']->info('DBManagerTest.vardefProvider: _db = ' . print_r($this->_db));
     $this->setUp();
     // Just in case the DB driver is not created yet.
     $emptydate = $this->_db->emptyValue("date");
     $emptytime = $this->_db->emptyValue("time");
     $emptydatetime = $this->_db->emptyValue("datetime");
     return array(array("testid", array('id' => array('name' => 'id', 'type' => 'varchar', 'required' => true)), array("id" => "test123"), array("id" => "'test123'")), array("testtext", array('text1' => array('name' => 'text1', 'type' => 'varchar', 'required' => true), 'text2' => array('name' => 'text2', 'type' => 'varchar')), array(), array("text1" => "''"), array()), array("testtext2", array('text1' => array('name' => 'text1', 'type' => 'varchar', 'required' => true), 'text2' => array('name' => 'text2', 'type' => 'varchar')), array('text1' => 'foo', 'text2' => 'bar'), array("text1" => "'foo'", 'text2' => "'bar'")), array("testreq", array('id' => array('name' => 'id', 'type' => 'varchar', 'required' => true), 'intval' => array('name' => 'intval', 'type' => 'int', 'required' => true), 'floatval' => array('name' => 'floatval', 'type' => 'decimal', 'required' => true), 'money' => array('name' => 'money', 'type' => 'currency', 'required' => true), 'test_dtm' => array('name' => 'test_dtm', 'type' => 'datetime', 'required' => true), 'test_dtm2' => array('name' => 'test_dtm2', 'type' => 'datetimecombo', 'required' => true), 'test_dt' => array('name' => 'test_dt', 'type' => 'date', 'required' => true), 'test_tm' => array('name' => 'test_tm', 'type' => 'time', 'required' => true)), array("id" => "test123", 'intval' => 42, 'floatval' => 42.24, 'money' => 56.78, 'test_dtm' => '2002-01-02 12:34:56', 'test_dtm2' => '2011-10-08 01:02:03', 'test_dt' => '1998-10-04', 'test_tm' => '03:04:05'), array("id" => "'test123'", 'intval' => 42, 'floatval' => 42.24, 'money' => 56.78, 'test_dtm' => $this->_db->convert('\'2002-01-02 12:34:56\'', "datetime"), 'test_dtm2' => $this->_db->convert('\'2011-10-08 01:02:03\'', 'datetime'), 'test_dt' => $this->_db->convert('\'1998-10-04\'', 'date'), 'test_tm' => $this->_db->convert('\'03:04:05\'', 'time'))), array("testreqnull", array('id' => array('name' => 'id', 'type' => 'varchar', 'required' => true), 'intval' => array('name' => 'intval', 'type' => 'int', 'required' => true), 'floatval' => array('name' => 'floatval', 'type' => 'decimal', 'required' => true), 'money' => array('name' => 'money', 'type' => 'currency', 'required' => true), 'test_dtm' => array('name' => 'test_dtm', 'type' => 'datetime', 'required' => true), 'test_dtm2' => array('name' => 'test_dtm2', 'type' => 'datetimecombo', 'required' => true), 'test_dt' => array('name' => 'test_dt', 'type' => 'date', 'required' => true), 'test_tm' => array('name' => 'test_tm', 'type' => 'time', 'required' => true)), array(), array("id" => "''", 'intval' => 0, 'floatval' => 0, 'money' => 0, 'test_dtm' => "{$emptydatetime}", 'test_dtm2' => "{$emptydatetime}", 'test_dt' => "{$emptydate}", 'test_tm' => "{$emptytime}"), array()), array("testnull", array('id' => array('name' => 'id', 'type' => 'varchar'), 'intval' => array('name' => 'intval', 'type' => 'int'), 'floatval' => array('name' => 'floatval', 'type' => 'decimal'), 'money' => array('name' => 'money', 'type' => 'currency'), 'test_dtm' => array('name' => 'test_dtm', 'type' => 'datetime'), 'test_dtm2' => array('name' => 'test_dtm2', 'type' => 'datetimecombo'), 'test_dt' => array('name' => 'test_dt', 'type' => 'date'), 'test_tm' => array('name' => 'test_tm', 'type' => 'time')), array("id" => 123), array("id" => "'123'"), array()), array("testempty", array('id' => array('name' => 'id', 'type' => 'varchar'), 'intval' => array('name' => 'intval', 'type' => 'int'), 'floatval' => array('name' => 'floatval', 'type' => 'decimal'), 'money' => array('name' => 'money', 'type' => 'currency'), 'test_dtm' => array('name' => 'test_dtm', 'type' => 'datetime'), 'test_dtm2' => array('name' => 'test_dtm2', 'type' => 'datetimecombo'), 'test_dt' => array('name' => 'test_dt', 'type' => 'date'), 'test_tm' => array('name' => 'test_tm', 'type' => 'time'), 'text_txt' => array('name' => 'test_txt', 'type' => 'varchar')), array("id" => "", 'intval' => '', 'floatval' => '', 'money' => '', 'test_dtm' => '', 'test_dtm2' => '', 'test_dt' => '', 'test_tm' => '', 'text_txt' => null), array("id" => "''", 'intval' => 0, 'floatval' => 0, 'money' => 0, 'test_dtm' => "NULL", 'test_dtm2' => "NULL", 'test_dt' => "NULL", 'test_tm' => 'NULL'), array('intval' => 'NULL', 'floatval' => 'NULL', 'money' => 'NULL', 'test_dtm' => 'NULL', 'test_dtm2' => 'NULL', 'test_dt' => 'NULL', 'test_tm' => 'NULL')));
 }
Example #2
0
 /**
  * Return representation of an empty value depending on type
  * @param string $type
  */
 public function emptyValue($type)
 {
     $ctype = $this->getColumnType($type);
     if ($ctype == "datetime") {
         return $this->convert($this->quoted("1970-01-01 00:00:00"), "datetime");
     }
     if ($ctype == "date") {
         return $this->convert($this->quoted("1970-01-01"), "datetime");
     }
     if ($ctype == "time") {
         return $this->convert($this->quoted("00:00:00"), "time");
     }
     return parent::emptyValue($type);
 }
Example #3
0
 public function emptyValue($type)
 {
     // http://www.devx.com/dbzone/Article/28713
     // http://publib.boulder.ibm.com/infocenter/db2luw/v9r7/index.jsp?topic=/com.ibm.db2.luw.sql.ref.doc/doc/r0008474.html
     $ctype = $this->getColumnType($type);
     if ($ctype == "datetime" || $ctype == "timestamp") {
         return $this->convert($this->quoted("0001-01-01 00:00:00"), "datetime");
     }
     if ($ctype == "date") {
         return $this->convert($this->quoted("0001-01-01"), "date");
     }
     if ($ctype == "time") {
         return $this->convert($this->quoted("00:00:00"), "time");
     }
     return parent::emptyValue($type);
 }
Example #4
0
 public function emptyValue($type, $forPrepared = false)
 {
     $ctype = $this->getColumnType($type);
     if ($ctype == "datetime") {
         return $forPrepared ? "1970-01-01 00:00:00" : $this->convert($this->quoted("1970-01-01 00:00:00"), "datetime");
     }
     if ($ctype == "date") {
         return $forPrepared ? "1970-01-01" : $this->convert($this->quoted("1970-01-01"), "date");
     }
     if ($ctype == "time") {
         return $forPrepared ? "00:00:00" : $this->convert($this->quoted("00:00:00"), "time");
     }
     if ($ctype == "clob") {
         return "EMPTY_CLOB()";
     }
     if ($ctype == "blob") {
         return "EMPTY_BLOB()";
     }
     return parent::emptyValue($type, $forPrepared);
 }