Example #1
0
 /**
  * Inserts fake data into the users table.
  *
  * @param int $amount The number of rows to insert.
  */
 private function insertFakeData($amount = 1)
 {
     if ((int) $amount < 1) {
         $amount = 1;
     }
     for ($i = 0; $i < $amount; $i++) {
         Query::insert()->into('users')->values(array('user_name' => '{string:user_name}', 'user_email' => '{string:user_email}', 'user_status' => '{int:user_status}'))->replace(array('user_name' => 'user' . ($i + 1), 'user_email' => 'user' . ($i + 1) . '@outlook.com', 'user_status' => mt_rand(0, 2)))->execute();
     }
 }
 /**
  * Sets up the InsertQuery instance.
  */
 public function setUp()
 {
     $this->insertQuery = Query::insert();
 }
 /**
  * @expectedException \Queryer\Exception\DatabaseException
  * @expectedExceptionMessage Row keys do not match, found at row values 2, 3 and 4.
  * @expectedExceptionCode \Queryer\Exception\DatabaseException::INVALID_QUERY
  */
 public function testInsertRowsDoNotMatchException()
 {
     $query = Query::insert()->ignore(true)->into('mytable')->values(array('user_id' => 1, 'user_name' => '\'username\''))->values(array('user_id' => 2))->values(array('random' => 'yup'))->values(array('mismatch' => 'yes'));
     MysqlDriver::generateQuery($query->getOptions());
 }