Esempio n. 1
0
 public function testAddingAutoIncrementField()
 {
     $dbh = $this->db;
     $schema1 = new ezcDbSchema(array('table10801' => new ezcDbSchemaTable(array('id' => ezcDbSchemaField::__set_state(array('type' => 'integer', 'length' => false, 'notNull' => false, 'default' => 0, 'autoIncrement' => false, 'unsigned' => false)), 'text' => new ezcDbSchemaField('text')))));
     $schema2 = new ezcDbSchema(array('table10801' => new ezcDbSchemaTable(array('id' => ezcDbSchemaField::__set_state(array('type' => 'integer', 'length' => false, 'notNull' => true, 'default' => null, 'autoIncrement' => true, 'unsigned' => false)), 'text' => new ezcDbSchemaField('text')))));
     $schema1->writeToDb($dbh);
     $diff = ezcDbSchemaComparator::compareSchemas($schema1, $schema2);
     $diff->applyToDb($dbh);
     $q = $dbh->createInsertQuery();
     $stmt = $q->insertInto($dbh->quoteIdentifier('table10801'))->set($dbh->quoteIdentifier('text'), $q->bindValue('text'))->prepare();
     $stmt->execute();
     $q = $dbh->createSelectQuery();
     $stmt = $q->select('*')->from($dbh->quoteIdentifier('table10801'))->prepare();
     $stmt->execute();
     $result = $stmt->fetchAll(PDO::FETCH_ASSOC);
     $this->assertEquals(1, $result[0]['id']);
 }
 public function testSetStateCastValues()
 {
     $a = array();
     $a['type'] = 'integer';
     $a['length'] = '42';
     $a['notNull'] = 1;
     $a['default'] = true;
     $a['autoIncrement'] = '0';
     $a['unsigned'] = 'true';
     $schemaField = ezcDbSchemaField::__set_state($a);
     self::assertEquals($schemaField->type, 'integer');
     self::assertEquals($schemaField->length, 42);
     self::assertEquals($schemaField->notNull, true);
     self::assertEquals($schemaField->default, true);
     self::assertEquals($schemaField->autoIncrement, false);
     self::assertEquals($schemaField->unsigned, true);
 }
Esempio n. 3
0
<?php

return array('ce_bad_word' => ezcDbSchemaTable::__set_state(array('fields' => array('badword_id' => ezcDbSchemaField::__set_state(array('type' => 'integer', 'length' => 0, 'notNull' => false, 'default' => NULL, 'autoIncrement' => false, 'unsigned' => false)), 'substitution' => ezcDbSchemaField::__set_state(array('type' => 'text', 'length' => 0, 'notNull' => false, 'default' => NULL, 'autoIncrement' => false, 'unsigned' => false)), 'word' => ezcDbSchemaField::__set_state(array('type' => 'text', 'length' => 0, 'notNull' => false, 'default' => NULL, 'autoIncrement' => false, 'unsigned' => false))), 'indexes' => array())), 'ce_message_category_rel' => ezcDbSchemaTable::__set_state(array('fields' => array('category_id' => ezcDbSchemaField::__set_state(array('type' => 'integer', 'length' => 0, 'notNull' => false, 'default' => NULL, 'autoIncrement' => false, 'unsigned' => false)), 'is_shadow' => ezcDbSchemaField::__set_state(array('type' => 'boolean', 'length' => 0, 'notNull' => false, 'default' => false, 'autoIncrement' => false, 'unsigned' => false)), 'message_id' => ezcDbSchemaField::__set_state(array('type' => 'integer', 'length' => 0, 'notNull' => false, 'default' => NULL, 'autoIncrement' => false, 'unsigned' => false))), 'indexes' => array())), 'debugger' => ezcDbSchemaTable::__set_state(array('fields' => array('session_id' => ezcDbSchemaField::__set_state(array('type' => 'text', 'length' => 0, 'notNull' => false, 'default' => NULL, 'autoIncrement' => false, 'unsigned' => false))), 'indexes' => array())), 'liveuser_translations' => ezcDbSchemaTable::__set_state(array('fields' => array('description' => ezcDbSchemaField::__set_state(array('type' => 'text', 'length' => 0, 'notNull' => false, 'default' => NULL, 'autoIncrement' => false, 'unsigned' => false)), 'language_id' => ezcDbSchemaField::__set_state(array('type' => 'text', 'length' => 0, 'notNull' => false, 'default' => NULL, 'autoIncrement' => false, 'unsigned' => false)), 'name' => ezcDbSchemaField::__set_state(array('type' => 'text', 'length' => 0, 'notNull' => false, 'default' => NULL, 'autoIncrement' => false, 'unsigned' => false)), 'section_id' => ezcDbSchemaField::__set_state(array('type' => 'integer', 'length' => 0, 'notNull' => false, 'default' => NULL, 'autoIncrement' => false, 'unsigned' => false)), 'section_type' => ezcDbSchemaField::__set_state(array('type' => 'integer', 'length' => 0, 'notNull' => false, 'default' => NULL, 'autoIncrement' => false, 'unsigned' => false)), 'translation_id' => ezcDbSchemaField::__set_state(array('type' => 'integer', 'length' => 0, 'notNull' => true, 'default' => '0', 'autoIncrement' => true, 'unsigned' => false))), 'indexes' => array(0 => ezcDbSchemaIndex::__set_state(array('indexFields' => array('translation_id' => ezcDbSchemaIndexField::__set_state(array('sorting' => NULL))), 'primary' => true, 'unique' => false))))));