Skip to content

Commit

Permalink
debug group creation with postgresql db removing "`" characters aroun…
Browse files Browse the repository at this point in the history
…d column names and using Yii CDbCommandBuilder::getLastInsertID()
  • Loading branch information
geelweb committed Sep 26, 2012
1 parent a211996 commit 0770f78
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions application/models/User_groups.php
Expand Up @@ -124,11 +124,11 @@ function join($fields, $from, $condition=FALSE, $join=FALSE, $order=FALSE)
}

function addGroup($group_name, $group_description) {
$iquery = "INSERT INTO {{user_groups}} (`name`, `description`, `owner_id`) VALUES(:group_name, :group_desc, :loginID)";
$iquery = "INSERT INTO {{user_groups}} (name, description, owner_id) VALUES(:group_name, :group_desc, :loginID)";
$command = Yii::app()->db->createCommand($iquery)->bindParam(":group_name", $group_name, PDO::PARAM_STR)->bindParam(":group_desc", $group_description, PDO::PARAM_STR)->bindParam(":loginID", intval(Yii::app()->session['loginID']), PDO::PARAM_INT);
$result = $command->query();
if($result) { //Checked
$id = Yii::app()->db->getLastInsertID(); //Yii::app()->db->Insert_Id(db_table_name_nq('user_groups'),'ugid');
$id = Yii::app()->db->getCommandBuilder()->getLastInsertID($this->tableName()); //Yii::app()->db->Insert_Id(db_table_name_nq('user_groups'),'ugid');
if($id > 0) {
$user_in_groups_query = 'INSERT INTO {{user_in_groups}} (ugid, uid) VALUES (:ugid, :uid)';
$command = Yii::app()->db->createCommand($user_in_groups_query)->bindParam(":ugid", $id, PDO::PARAM_INT)->bindParam(":uid", intval(Yii::app()->session['loginID']), PDO::PARAM_INT)->query();
Expand All @@ -149,7 +149,7 @@ function updateGroup($name, $description, $ugid)
if ($group->getErrors())
return false;
else
return true;
return true;
}

function requestEditGroup($ugid, $ownerid)
Expand All @@ -176,7 +176,7 @@ function deleteGroup($ugid, $ownerid)
$group->delete();
if($group->getErrors())
return false;
else
else
return true;
}

Expand Down

0 comments on commit 0770f78

Please sign in to comment.