Skip to content

Commit

Permalink
5527 added ac_insert_id() function
Browse files Browse the repository at this point in the history
  • Loading branch information
atutorlangs committed Sep 8, 2014
1 parent a704fa3 commit 946f3cd
Show file tree
Hide file tree
Showing 20 changed files with 53 additions and 27 deletions.
1 change: 1 addition & 0 deletions home/course/course_property.php
Expand Up @@ -21,6 +21,7 @@
require_once(TR_INCLUDE_PATH.'classes/DAO/ContentForumsAssocDAO.class.php');
require_once(TR_INCLUDE_PATH.'classes/DAO/TestsDAO.class.php');
require_once(TR_INCLUDE_PATH.'classes/DAO/ContentTestsAssocDAO.class.php');
require_once(TR_INCLUDE_PATH.'lib/mysql_funcs.inc.php');

global $_course_id;

Expand Down
13 changes: 11 additions & 2 deletions include/classes/A4a/A4a.class.php
Expand Up @@ -167,7 +167,7 @@ function setPrimaryResource($content_id, $file_name, $lang){
$primaryResourcesDAO = new PrimaryResourcesDAO();

if ($primaryResourcesDAO->Create($content_id, $file_name, $lang)){
return ac_insert_id();
return $this->ac_insert_id();
}
return false;
}
Expand All @@ -185,7 +185,7 @@ function setSecondaryResource($primary_resource_id, $file_name, $lang){
include_once(TR_INCLUDE_PATH.'classes/DAO/SecondaryResourcesDAO.class.php');
$secondaryResourcesDAO = new SecondaryResourcesDAO();
if ($secondaryResourcesDAO->Create($primary_resource_id, $file_name, $lang)){
return ac_insert_id();
return $this->ac_insert_id();
}
return false;
}
Expand Down Expand Up @@ -220,6 +220,15 @@ function deleteA4a(){
$primaryResourcesDAO = new PrimaryResourcesDAO();
$rows = $primaryResourcesDAO->Delete($this->cid);
}

function ac_insert_id(){
global $db;
if(defined('MYSQLI_ENABLED')){
return self::$db->insert_id;
}else{
return mysql_insert_id(self::$db);
}
}
}

?>
2 changes: 1 addition & 1 deletion include/classes/DAO/ContentDAO.class.php
Expand Up @@ -76,7 +76,7 @@ public function Create($course_id, $content_parent_id, $ordering, $revision, $fo
{

//$cid = mysql_insert_id();
$cid = ac_insert_id();
$cid = $this->ac_insert_id();

// update the courses.modified_date to the current timestamp
include_once(TR_INCLUDE_PATH.'classes/DAO/CoursesDAO.class.php');
Expand Down
2 changes: 1 addition & 1 deletion include/classes/DAO/CourseCategoriesDAO.class.php
Expand Up @@ -51,7 +51,7 @@ public function Create($categoryName)
else
{
//return mysql_insert_id();
return ac_insert_id();
return $this->ac_insert_id();
}
}
else
Expand Down
2 changes: 1 addition & 1 deletion include/classes/DAO/CoursesDAO.class.php
Expand Up @@ -87,7 +87,7 @@ public function Create($user_id, $content_packaging, $access, $title, $descripti
else
{
//$course_id = mysql_insert_id();
$course_id = c_insert_id();
$course_id = $this->ac_insert_id();
// create the user and course relationship
$sql = "INSERT INTO ".TABLE_PREFIX."user_courses (user_id, course_id, role, last_cid)
VALUES (".$user_id.", ".$course_id.", ".TR_USERROLE_AUTHOR.", 0)";
Expand Down
9 changes: 8 additions & 1 deletion include/classes/DAO/DAO.class.php
Expand Up @@ -128,6 +128,13 @@ function execute($sql)
return true;
}
}

function ac_insert_id(){
//global $db;
if(defined('MYSQLI_ENABLED')){
return self::$db->insert_id;
}else{
return mysql_insert_id(self::$db);
}
}
}
?>
2 changes: 1 addition & 1 deletion include/classes/DAO/ForumsDAO.class.php
Expand Up @@ -55,7 +55,7 @@ public function Create($title, $description)
else
{
//return mysql_insert_id();
return ac_insert_id();
return $this->ac_insert_id();
}
}
else
Expand Down
2 changes: 1 addition & 1 deletion include/classes/DAO/MyownPatchesDAO.class.php
Expand Up @@ -62,7 +62,7 @@ public function Create($system_patch_id, $applied_version,
else
{
//return mysql_insert_id();
return ac_insert_id();
return $this->ac_insert_id();
}
}

Expand Down
2 changes: 1 addition & 1 deletion include/classes/DAO/MyownPatchesDependentDAO.class.php
Expand Up @@ -51,7 +51,7 @@ public function Create($myown_patch_id, $dependent_patch_id)
else
{
//return mysql_insert_id();
return ac_insert_id();
return $this->ac_insert_id();
}
}

Expand Down
2 changes: 1 addition & 1 deletion include/classes/DAO/MyownPatchesFilesDAO.class.php
Expand Up @@ -67,7 +67,7 @@ public function Create($myown_patch_id, $action, $name, $location,
else
{
//return mysql_insert_id();
return ac_insert_id();
return $this->ac_insert_id();
}
}

Expand Down
2 changes: 1 addition & 1 deletion include/classes/DAO/OAuthServerConsumersDAO.class.php
Expand Up @@ -83,7 +83,7 @@ public function Create($consumer, $expire_threshold)
else
{
//return mysql_insert_id();
return ac_insert_id();
return $this->ac_insert_id();
}
}
else
Expand Down
2 changes: 1 addition & 1 deletion include/classes/DAO/PatchesDAO.class.php
Expand Up @@ -85,7 +85,7 @@ public function Create($system_patch_id, $applied_version,
else
{
//return mysql_insert_id();
return ac_insert_id();
return $this->ac_insert_id();
}
}

Expand Down
2 changes: 1 addition & 1 deletion include/classes/DAO/PatchesFilesActionsDAO.class.php
Expand Up @@ -56,7 +56,7 @@ public function Create($patches_files_id, $action, $code_from, $code_to)
else
{
//return mysql_insert_id();
return ac_insert_id();
return $this->ac_insert_id();
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion include/classes/DAO/PatchesFilesDAO.class.php
Expand Up @@ -56,7 +56,7 @@ public function Create($patch_id, $action, $name, $location)
else
{
//return mysql_insert_id();
return ac_insert_id();
return $this->ac_insert_id();
}
}

Expand Down
2 changes: 1 addition & 1 deletion include/classes/DAO/TestsDAO.class.php
Expand Up @@ -52,7 +52,7 @@ public function Create($course_id, $title, $description)
}
else
{
return ac_insert_id();
return $this->ac_insert_id();
}
}
else
Expand Down
2 changes: 1 addition & 1 deletion include/classes/DAO/TestsQuestionsCategoriesDAO.class.php
Expand Up @@ -50,7 +50,7 @@ public function Create($courseID, $title)
}
else
{
return ac_insert_id();
return $this->ac_insert_id();
}
}
else
Expand Down
2 changes: 1 addition & 1 deletion include/classes/DAO/UserGroupsDAO.class.php
Expand Up @@ -72,7 +72,7 @@ public function Create($title, $description)
}
else
{
return ac_insert_id();
return $this->ac_insert_id();
}
}
else
Expand Down
14 changes: 7 additions & 7 deletions include/classes/testQuestions.class.php
Expand Up @@ -788,7 +788,7 @@ function importQTI($question){

$dao = new DAO();
if ($dao->execute($sql)) {
return ac_insert_id();
return $dao->ac_insert_id();

}
}
Expand Down Expand Up @@ -872,7 +872,7 @@ function importQTI($question){

$dao = new DAO();
if ($dao->execute($sql)) {
return ac_insert_id();
return $dao->ac_insert_id();
}
}
}
Expand Down Expand Up @@ -1004,7 +1004,7 @@ function importQTI($question){

$dao = new DAO();
if ($dao->execute($sql)) {
return ac_insert_id();
return $dao->ac_insert_id();
}
}
}
Expand Down Expand Up @@ -1077,7 +1077,7 @@ function importQTI($question){

$dao = new DAO();
if ($dao->execute($sql)) {
return ac_insert_id();
return $dao->ac_insert_id();
}
}
}
Expand Down Expand Up @@ -1276,7 +1276,7 @@ function importQTI($question){

$dao = new DAO();
if ($dao->execute($sql)) {
return ac_insert_id();
return $dao->ac_insert_id();
}
}
}
Expand Down Expand Up @@ -1427,7 +1427,7 @@ function importQTI($question){
$sql = vsprintf(TR_SQL_QUESTION_MULTI, $sql_params);
$dao = new DAO();
if ($dao->execute($sql)) {
return ac_insert_id();
return $dao->ac_insert_id();
}
}
}
Expand Down Expand Up @@ -1564,7 +1564,7 @@ function importQTI($question){

$dao = new DAO();
if ($dao->execute($sql)) {
return ac_insert_id();
return $dao->ac_insert_id();
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions include/lib/mysql_funcs.inc.php
Expand Up @@ -52,7 +52,7 @@ function getMySQLVersion() {
preg_match('@[0-9]+\.[0-9]+\.[0-9]+@', $output, $version);
return $version[0];
}

/*
function at_db_select($db_name, $db){
if(defined('MYSQLI_ENABLED')){
if(!$db->select_db($db_name)){
Expand All @@ -73,4 +73,4 @@ function at_db_select($db_name, $db){
}
}
}
}*/
11 changes: 10 additions & 1 deletion updater/classes/PatchCreator.class.php
Expand Up @@ -163,7 +163,7 @@ function saveInfo()
if ($this->current_patch_id == 0)
{
//$this->current_patch_id = mysql_insert_id();
$this->current_patch_id = ac_insert_id();
$this->current_patch_id = $this->ac_insert_id();
}
else // delete records for current_patch_id in tables myown_patches_dependent & myown_patches_files
{
Expand Down Expand Up @@ -358,5 +358,14 @@ function htmlNewLine($str)
else
return $str;
}
function ac_insert_id(){
global $db;
if(defined('MYSQLI_ENABLED')){
return self::$db->insert_id;
}else{
return mysql_insert_id(self::$db);
}
}

}
?>

0 comments on commit 946f3cd

Please sign in to comment.