public function insert($table, array $data)
    {
        $table = $this->getTable($table);
        $field = implode(', ', array_keys($data));

        $placeholder = array();
        foreach ($data as $key => $value) {
            if ($value instanceof \stdClass && isset($value->scalar)) {
                $placeholder[] = $value->scalar;
                unset($data[$key]);
            } else {
                $placeholder[] = '?';
            }
        }
        $placeholder = implode(', ', $placeholder);

        $query = "INSERT INTO $table ($field) VALUES ($placeholder)";
        return $this->executeUpdate($query, array_values($data));
    }
public function insert($table, array $data)
    {
        $table = $this->getTable($table);
        $field = implode(', ', array_keys($data));

        $placeholder = array();
        foreach ($data as $key => $value) {
            if ($value instanceof \stdClass && isset($value->scalar)) {
                $placeholder[] = $value->scalar;
                unset($data[$key]);
            } else {
                $placeholder[] = '?';
            }
        }
        $placeholder = implode(', ', $placeholder);

        $query = "INSERT INTO $table ($field) VALUES ($placeholder)";
        return $this->executeUpdate($query, array_values($data));
    }
public function insert ( $ table , array $ data ) { $ table = $ this -> getTable ( $ table ) ; $ field = implode ( ', ' , array_keys ( $ data ) ) ; $ placeholder = array ( ) ; foreach ( $ data as $ key => $ value ) { if ( $ value instanceof \ stdClass && isset ( $ value -> scalar ) ) { $ placeholder [ ] = $ value -> scalar ; unset ( $ data [ $ key ] ) ; } else { $ placeholder [ ] = '?' ; } } $ placeholder = implode ( ', ' , $ placeholder ) ; $ query = "INSERT INTO $table ($field) VALUES ($placeholder)" ; return $ this -> executeUpdate ( $ query , array_values ( $ data ) ) ; }
Executes an INSERT query to insert specified data into table

@param string $table The name of table
@param array $data An associative array containing column-value pairs
@return int The number of affected rows
Executes an INSERT query to insert specified data into table