I have the following class:
public string Nome;
public int Cpf;
public string getNome() {
return Nome;
}
public void setNome(string nome) {
this.Nome = nome;
}
public int getCpf() {
return Cpf;
}
public void setCpf(int cpf) {
this.Cpf = cpf;
}
How can I convert to an array?
I want to create a function for the database where I need to pass only the table name and a Array
or OrderedDictionary
with the mapping of this class, to avoid having to change the query
each time I want to add a new attribute to it, I have this function in php
and I'm trying to pass c#
and the first thing I need to do is this conversion, in php
I use the function implode()
with array_keys()
to separate the keys
name of the fields in the database and the fields that will be inserted in the database. in the end I have a query
so INSERT INTO {$table} ( {$fields} ) VALUES ( {$values})";
that serves to insert values in any table.