note 118029 deleted from function.join by sobak
| From: | sobak@php.net | Date: | Thu, 17 Nov 2016 06:19:52 +0000 |
| Subject: | note 118029 deleted from function.join by sobak | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-207127@lists.php.net to get a copy of this message | ||
Note Submitter: fardinf2r at gmail dot com
----
class example{
public function create(){
global $database;
$attributes = $this->get_object_vars($this);
$sql = "INSERT INTO ". self::$table_name ." (";
$sql .= join(", ",array_keys($attributes));
$sql .= ") VALUES ('";
$sql .= join("', '", array_values($attributes));
$sql .= "')";
if($database->query($sql)){
$this->id = $database->insert_id();
return true;
}else{
return false;
}
}
}