Performs the actual database insert
@return string
426759
protected function doInsert()
    {
        //check if there is an error from previous function execution
        if (static::$response["status"] == "error") {
           return static::terminate(static::$response);
        }
        //convert each columns to ? parameter
        $columnParam = array_map(function () {
            return '?';
        }, $this->values);


        $sql = /** @lang sql */
            'INSERT INTO ' . self::$table .
            ' (' . $this->columns .
            ') VALUES(' . implode(',', $columnParam) . ')';

            $ext=array_map(function ($column){
                return $column.'=VALUES('.$column.')';
            },explode(',',$this->columns));
            if($this->updateOrInsert){ //if update when duplicate is found is set to true
                $sql.=' ON DUPLICATE KEY UPDATE '.implode(',',$ext);
            }

        try {
            $stm = Connect::getConn()->prepare($sql);
        } catch (Exception $e) {
            static::$response["status"] = "error";
            static::$response["response"] = $e->getMessage();
            static::$response["code"] = $e->getCode();
           return static::terminate(static::$response);
        }

        try {
            $stm->execute($this->values);

            static::$response["status"] = "success";
            static::$response["response"] = "success";
            static::$response["code"] = 200;

            return static::terminate(static::$response);
        } catch (Exception $e) {
            static::$response["status"] = "error";
            static::$response["response"] = $e->getMessage();
            static::$response["code"] = $e->getCode();
            return static::terminate(static::$response);
        }
    }
1371781
public function save()
	{
		$sQuery = $this->_prepare();

		if (preg_match('/INSERT INTO/i', $sQuery)) {

			$oDb = self::connect();
			$oDb->exec($sQuery);
			$this->flush();
			return $oDb->lastInsertId();
		}
		else {

			$this->flush();

			if ($this->_mWhere instanceof Where) { $this->_mWhere->flush(); }

			return self::connect()->exec($sQuery);
		}

	}
369888
private function insert()
    {
        $Eresus = Eresus_CMS::getLegacyKernel();

        $item = array();
        $item['caption'] = arg('caption', 'dbsafe');
        $item['active'] = arg('active', 'int');
        if (arg('section'))
        {
            $item['section'] = '|' . implode('|', arg('section')) . '|';
        }
        $item['block'] = arg('block', 'dbsafe');
        $item['priority'] = arg('priority', 'int');
        $item['showFrom'] = arg('showFrom', 'dbsafe');
        if (arg('showTill'))
        {
            $item['showTill'] = arg('showTill', 'dbsafe');
        }
        $item['showCount'] = arg('showCount', 'int');
        $item['html'] = arg('html', 'dbsafe');
        $item['image'] = arg('image');
        $item['width'] = arg('width', 'int');
        $item['height'] = arg('height', 'int');
        $item['url'] = arg('url', 'dbsafe');
        $item['target'] = arg('target', 'dbsafe');

        $Eresus->db->insert($this->table['name'], $item);

        $item['id'] = $Eresus->db->getInsertedID();
        if (is_uploaded_file($_FILES['image']['tmp_name']))
        {
            $filename = 'banner' . $item['id'] . substr($_FILES['image']['name'],
                    strrpos($_FILES['image']['name'], '.'));
            upload('image', $Eresus->fdata . $this->name . '/' . $filename);
            $item['image'] = $filename;
            $Eresus->db->updateItem($this->table['name'], $item, "`id`='" . $item['id'] . "'");
        }
        HTTP::redirect(arg('submitURL'));
    }
768037
public function insert()
    {
        Observer::dispatch(Observer::EVENT_ITEM_INSERT_BEFORE, array(
            'item' => $this
        ));

        $this->{static::DATEADDFIELD} = DateData::now();
        $insert = new Insert($this->_dbContainer);
        $insert->addFields($this->_fields);
        $insert->commit();
        $this->setId($insert->getId());
        $this->_origFields = $this->_fields;

        Observer::dispatch(Observer::EVENT_ITEM_INSERT_AFTER, array(
            'item' => $this
        ));

        return $this;
    }
921869
protected function insertRow()
    {   
        $assignedValues = $this->getAssignedValues();

        $columns = implode(', ', $assignedValues['columns']);
        $values = '\''.implode('\', \'', $assignedValues['values']).'\'';

        $tableName = $this->getTableName($this->className);

        $connection = Connection::connect();

        $insert = $connection->prepare('insert into '.$tableName.'('.$columns.') values ('.$values.')');
        var_dump($insert);
        if ($insert->execute()) { 
            return 'Row inserted successfully'; 
        } else { 
            var_dump($insert->errorInfo()); 
        } 
    }
293719
public function execute()
    {
        if($this->db === null) {
            $this->db = DB::getInstance();
        }
        return $this->db->execQuery($this);
    }
886584
public function execute()
    {
        if ($this->cursor) {
            return $this;
        }

        $this->db->execute();

        $this->cursor = $this->db->getCursor();

        return $this;
    }
1225863
protected function getInsertStatement(): string
    {
        $statement = '';
        if (!$this->isInsert()) {
            return $statement;
        }

        // insert语句
        $statement .= $this->getInsertString();

        // values
        if ($this->builder->getInsertValues()) {
            $statement .= ' ' . $this->getInsertValuesString();
        }

        return $statement;
    }
192704
public function run()
    {
        DB::table('languages')->insert([
            'name'        => 'English',
            'flag'        => '',
            'abbr'        => 'en',
            'script'    => 'Latn',
            'native'    => 'English',
            'active'    => '1',
            'default'    => '1',
        ]);

        DB::table('languages')->insert([
            'name'        => 'Romanian',
            'flag'        => '',
            'abbr'        => 'ro',
            'script'    => 'Latn',
            'native'    => 'română',
            'active'    => '1',
            'default'    => '0',
        ]);

        DB::table('languages')->insert([
            'name'        => 'French',
            'flag'        => '',
            'abbr'        => 'fr',
            'script'    => 'Latn',
            'native'    => 'français',
            'active'    => '0',
            'default'    => '0',
        ]);

        DB::table('languages')->insert([
            'name'        => 'Italian',
            'flag'        => '',
            'abbr'        => 'it',
            'script'    => 'Latn',
            'native'    => 'italiano',
            'active'    => '0',
            'default'    => '0',
        ]);

        DB::table('languages')->insert([
            'name'        => 'Spanish',
            'flag'        => '',
            'abbr'        => 'es',
            'script'    => 'Latn',
            'native'    => 'español',
            'active'    => '0',
            'default'    => '0',
        ]);

        DB::table('languages')->insert([
            'name'        => 'German',
            'flag'        => '',
            'abbr'        => 'de',
            'script'    => 'Latn',
            'native'    => 'Deutsch',
            'active'    => '0',
            'default'    => '0',
        ]);

        $this->command->info('Language seeding successful.');
    }
33112
public function execute()
	{
		$this->connect();

		// Take a local copy so that we don't modify the original query and cause issues later
		$sql = $this->replacePrefix((string) $this->sql);

		// Increment the query counter.
		$this->count++;

		// If debugging is enabled then let's log the query.
		if ($this->debug)
		{
			// Add the query to the object queue.
			$this->log(
				Log\LogLevel::DEBUG,
				'{sql}',
				array('sql' => $sql, 'category' => 'databasequery', 'trace' => debug_backtrace())
			);
		}

		// Reset the error values.
		$this->errorNum = 0;
		$this->errorMsg = '';

		// Execute the query.
		$this->executed = false;

		if ($this->prepared instanceof \mysqli_stmt)
		{
			// Bind the variables:
			if ($this->sql instanceof PreparableInterface)
			{
				$bounded =& $this->sql->getBounded();

				if (\count($bounded))
				{
					$params     = array();
					$typeString = '';

					foreach ($bounded as $key => $obj)
					{
						// Add the type to the type string
						$typeString .= $obj->dataType;

						// And add the value as an additional param
						$params[] = $obj->value;
					}

					// Make everything references for call_user_func_array()
					$bindParams   = array();
					$bindParams[] = &$typeString;

					for ($i = 0, $iMax = \count($params); $i < $iMax; $i++)
					{
						$bindParams[] = &$params[$i];
					}

					\call_user_func_array(array($this->prepared, 'bind_param'), $bindParams);
				}
			}

			$this->executed = $this->prepared->execute();
			$this->cursor   = $this->prepared->get_result();

			// If the query was successful and we did not get a cursor, then set this to true (mimics mysql_query() return)
			if ($this->executed && !$this->cursor)
			{
				$this->cursor = true;
			}
		}

		// If an error occurred handle it.
		if (!$this->executed)
		{
			$this->errorNum = (int) $this->connection->errno;
			$this->errorMsg = (string) $this->connection->error;

			// Check if the server was disconnected.
			if (!$this->connected())
			{
				try
				{
					// Attempt to reconnect.
					$this->connection = null;
					$this->connect();
				}
				catch (ConnectionFailureException $e)
				{
					// If connect fails, ignore that exception and throw the normal exception.
					$this->log(
						Log\LogLevel::ERROR,
						'Database query failed (error #{code}): {message}; Failed query: {sql}',
						array('code' => $this->errorNum, 'message' => $this->errorMsg, 'sql' => $sql)
					);

					throw new ExecutionFailureException($sql, $this->errorMsg, $this->errorNum);
				}

				// Since we were able to reconnect, run the query again.
				return $this->execute();
			}

			// The server was not disconnected.
			$this->log(
				Log\LogLevel::ERROR,
				'Database query failed (error #{code}): {message}; Failed query: {sql}',
				array('code' => $this->errorNum, 'message' => $this->errorMsg, 'sql' => $sql)
			);

			throw new ExecutionFailureException($sql, $this->errorMsg, $this->errorNum);
		}

		return $this->cursor;
	}
1099221
public function install()
    {
        $sql = 'CREATE TABLE IF NOT EXISTS `'.self::TABLENAME.'` (`id` varchar(32) NOT NULL, PRIMARY KEY (`id`), `session_data` longtext NULL, `access` int(10) NULL);';

        return $this->app['db']
            ->raw($sql)
            ->execute() instanceof PDOStatement;
    }
586495
public function execute()
	{
		$query  = $this->factory->builder($this->insert)->process();
		$result = $this->pdo->query($query);
		if(!$result)
		{
			throw new \Exception('An error is while the insertion occurred! (query: "' . $query . '")');
		}

		return $this->pdo->lastInsertId();
	}
1186652
public function run()
	{
		$i = 0;
		
		DB::table('conf')->insert([
			'slug' => 'email',
			'value' => 'somebody@somewhere.com',
			'ord' => $i++,
			'created_at' => date("Y-m-d H:i:s"),
			'updated_at' => date("Y-m-d H:i:s")
		]);
		DB::table('conf')->insert([
			'slug' => 'telephone',
			'value' => '070000000',
			'ord' => $i++,
			'created_at' => date("Y-m-d H:i:s"),
			'updated_at' => date("Y-m-d H:i:s")
		]);
		DB::table('conf')->insert([
			'slug' => 'facebook_url',
			'value' => 'http://facebook.com/',
			'ord' => $i++,
			'created_at' => date("Y-m-d H:i:s"),
			'updated_at' => date("Y-m-d H:i:s")
		]);
		DB::table('conf')->insert([
			'slug' => 'youtube_url',
			'value' => 'http://youtube.com/',
			'ord' => $i++,
			'created_at' => date("Y-m-d H:i:s"),
			'updated_at' => date("Y-m-d H:i:s")
		]);
		DB::table('conf')->insert([
			'slug' => 'googleplus_url',
			'value' => 'http://plus.google.com/',
			'ord' => $i++,
			'created_at' => date("Y-m-d H:i:s"),
			'updated_at' => date("Y-m-d H:i:s")
		]);
		DB::table('conf')->insert([
			'slug' => 'pinterest_url',
			'value' => 'http://pinterest.com/',
			'ord' => $i++,
			'created_at' => date("Y-m-d H:i:s"),
			'updated_at' => date("Y-m-d H:i:s")
		]);
		DB::table('conf')->insert([
			'slug' => 'ips',
			'value' => '',
			'ord' => $i++,
			'created_at' => date("Y-m-d H:i:s"),
			'updated_at' => date("Y-m-d H:i:s")
		]);
	}
733184
public function execute()
    {
        $databaseName = $this->databaseName === null ? $this->db->defaultDatabaseName : $this->databaseName;

        $token = $this->log([$databaseName, 'command'], $this->document, __METHOD__);

        try {
            $this->beginProfile($token, __METHOD__);

            $this->db->open();
            $mongoCommand = new \MongoDB\Driver\Command($this->document);
            $cursor = $this->db->manager->executeCommand($databaseName, $mongoCommand, $this->getReadPreference());
            $cursor->setTypeMap($this->db->typeMap);

            $this->endProfile($token, __METHOD__);
        } catch (RuntimeException $e) {
            $this->endProfile($token, __METHOD__);
            throw new Exception($e->getMessage(), $e->getCode(), $e);
        }

        return $cursor;
    }
964152
public function performQuery()
    {
        //change connection if provide
        if ($this->option('c')) {
            $this->schema->setConnection($this->option('c'));
            $this->schema->switchWrapper();
        }

        $rawQuery = $this->option('r');
        if (empty($rawQuery)) {
            $this->warn('Please provide raw sql query as string (in single/double quote)!');
            return false;
        }

         $result = $this->schema->rawQuery($rawQuery);
        if (!!$result) {
            (new Dumper)->dump($result);
        }
        $this->info('Query executed successfully!');
    }
329594
private function insert()
    {
        $db = new Db();

        //Pegando um ID válido
        $id = $db->query('SELECT MAX(id)id FROM article');
        $this->id = $id[0]->get('id')+1;

                //Insert into content table
        $row = $db->query('INSERT INTO articlecontent
                            SET article = :article,
                                editdate = :editdate,
                                content = :content',
                        [':article' => $this->id,
                         ':editdate' => $this->editdate,
                         ':content' => $this->content]);

        //check insert
        if (!$row) {
            //TODO: insert a ROWBACK if not inserted.

            return false;
        }
        
        //Insert into article table
        $row = $db->query('INSERT INTO article
                            SET id = :id,
                                category = :category,
                                author = :author,
                                pubdate = :pubdate,
                                editdate = :editdate,
                                link = :link,
                                tags = :tags,
                                status = :status,
                                title = :title,
                                media = :media,
                                resume = :resume ',
                        [':id'=>$this->id,
                         ':category' => $this->category,
                         ':author' => $this->author,
                         ':pubdate' => $this->pubdate,
                         ':editdate' => $this->editdate,
                         ':link' => $this->link,
                         ':tags' => $this->tags,
                         ':status' => $this->status,
                         ':title' => $this->title,
                         ':media' => $this->media,
                         ':resume' => $this->resume
                        ]);

        return $row;
    }
455547
public function insert()
    {
        self::$instance->reset();
        $this->sql('INSERT INTO ' . $this->oosql_table);

        $arg_list = func_get_args();
        $numargs = func_num_args();

        if ($numargs > 0) {
            $this->oosql_numargs = $numargs;
            $this->sql(' (');

            $this->sql(implode(',', $arg_list));

            $this->sql(')');
        }
        $this->oosql_insert = true;
        return $this;
    }