epifanio67
asked on
mysql: please explain beginning of this method. Thanks
Hello Experts,
what does this mean?
' ( %s ) VALUES ( %s ) '
in the beginning of the method below? this is string (single quotes)... the values seems to come from the second object param...
thanks,
what does this mean?
' ( %s ) VALUES ( %s ) '
in the beginning of the method below? this is string (single quotes)... the values seems to come from the second object param...
thanks,
function insertObject( $table, &$object, $keyName = NULL ) {
$fmtsql = 'INSERT INTO '.$this->nameQuote($table).' (%s)VALUES(%s)'; //I am not sure how these values are obtained to do an insert
$fields = array();
foreach (get_object_vars( $object ) as $k => $v) {
if (is_array($v) or is_object($v) or $v === NULL) {
continue;
}
if ($k[0] == '_') { // internal field
continue;
}
$fields[] = $this->nameQuote( $k );
$values[] = $this->isQuoted( $k ) ? $this->Quote( $v ) : (int) $v;
}
$this->setQuery( sprintf( $fmtsql, implode( ",", $fields ) , implode( ",", $values ) ) );
if (!$this->query()) {
return false;
}
$id = $this->insertid();
if ($keyName && $id) {
$object->$keyName = $id;
}
return true;
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER