本文整理汇总了PHP中album::insert方法的典型用法代码示例。如果您正苦于以下问题:PHP album::insert方法的具体用法?PHP album::insert怎么用?PHP album::insert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类album
的用法示例。
在下文中一共展示了album::insert方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: insert
function insert()
{
global $database_table_prefix;
if (!empty($this->artist)) {
$result = mysql_query("\n\t\t\t\tSELECT *\n\t\t\t\tFROM `" . $database_table_prefix . "artist`\n\t\t\t\tWHERE `name` = '" . addslashes($this->artist) . "'\n\t\t\t") or die(mysql_error());
if (mysql_num_rows($result) == 0) {
$artist = new artist();
$artist->name = $this->artist;
$artist->insert();
$this->artist_id = $artist->id;
} else {
while ($data = mysql_fetch_object($result)) {
$this->artist_id = $data->id;
}
}
}
if (!empty($this->album)) {
$result = mysql_query("\n\t\t\t\tSELECT *\n\t\t\t\tFROM `" . $database_table_prefix . "album`\n\t\t\t\tWHERE `name` = '" . addslashes($this->album) . "'\n\t\t\t\tAND `artist` = '" . addslashes($this->artist_id) . "'\n\t\t\t") or die(mysql_error());
if (mysql_num_rows($result) == 0) {
$album = new album();
$album->name = $this->album;
$album->artist = $this->artist_id;
$album->insert();
$this->album_id = $album->id;
} else {
while ($data = mysql_fetch_object($result)) {
$this->album_id = $data->id;
}
}
}
$result = mysql_query("\n\t\t\tINSERT \n\t\t\tINTO `" . $database_table_prefix . "song`\n\t\t\t( `name`\n\t\t\t, `rating`\n\t\t\t, `play_count`\n\t\t\t, `artist`\n\t\t\t, `album`\n\t\t\t)\n\t\t\tVALUES \n\t\t\t( '" . addslashes($this->name) . "'\n\t\t\t, '" . addslashes($this->rating) . "'\n\t\t\t, '" . addslashes($this->play_count) . "'\n\t\t\t, '" . addslashes($this->artist_id) . "'\n\t\t\t, '" . addslashes($this->album_id) . "'\n\t\t\t)\n\t\t") or die(mysql_error());
$this->id = mysql_insert_id();
}