Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

SaveRelationship now returns boolean

  • Loading branch information...
commit 46d81e4f89f4ae28d8284754ee648fb1cacb9e4c 1 parent c879ae6
@klederson authored
View
2  app/generator/structure/config.php
@@ -19,7 +19,7 @@
################################
# Getting current session if exists
################################
-session_name(PHPBURN_SESSIONNAME);
+session_name(SYS_SESSION_NAME);
session_start();
View
2  app/generator/structure/sysConfig.php
@@ -54,7 +54,7 @@
################################
# Infos
################################
-define('PHPBURN_SESSIONNAME', md5(SYS_BASE_PATH), true);
+define('SYS_SESSION_NAME', md5(SYS_BASE_PATH), true);
define('PHPBURN_VERSION','0.9b',true);
define('PHPBURN_WEBSITE','http://www.phpburn.com/',true);
define('PHPBURN_REPOSITORY_TYPE','git',true);
View
2  app/generator/structure/system/config/spices/acl.spices.php
@@ -38,7 +38,7 @@
'defaultType' => 'unknown',
'authInfo' => array(
- 'allowedMethods' => &$_SESSION['phpburn']['userInfo']['allowedMethods']
+ 'allowedMethods' => &$_SESSIONSYS_SESSION_NAME['userInfo']['allowedMethods']
)
);
View
2  app/libs/Connection/MySQL.php
@@ -354,7 +354,7 @@ public function executeSQL($sql)
{
$msg = "[!Database error:!] " . $this->getErrorMsg();
PhpBURN_Message::output($msg, PhpBURN_Message::ERROR);
- return false;
+ return FALSE;
//$this->dispatchEvent('onExecuteError', $this, $sql, $msg);
}
//$this->close();
View
48 app/libs/Connection/MySQLi.php 100755 → 100644
@@ -16,7 +16,7 @@
* @author Klederson Bueno Bezerra da Silva
*
*/
-class PhpBURN_Connection_MySQL implements IConnection
+class PhpBURN_Connection_MySQLi implements IConnection
{
const CLOSED = 100201;
@@ -52,7 +52,7 @@ static public function getInstance()
{
if(self::$instance == null)
{
- self::$instance = new PhpBURN_Connection_MySQL();
+ self::$instance = new PhpBURN_Connection_MySQLi();
}
return self::$instance;
@@ -63,7 +63,7 @@ public function connect()
if($this->conn_id && $this->state == self::OPEN)
{
- mysql_select_db($this->getDatabase(), $this->conn_id);
+ mysqli_select_db($this->conn_id,$this->getDatabase());
return true;
}
@@ -82,9 +82,9 @@ public function connect()
if(isset($this->options['persistent']) && $this->options['persistent'] == true)
{
- $this->conn_id = @mysql_pconnect($hostString, $this->getUser(), $this->getPassword(), $flags);
+ $this->conn_id = @mysqli_pconnect($hostString, $this->getUser(), $this->getPassword(), $flags);
} else {
- $this->conn_id = @mysql_connect($hostString, $this->getUser(), $this->getPassword(), $flags);
+ $this->conn_id = @mysqli_connect($hostString, $this->getUser(), $this->getPassword(), $flags);
}
if( !$this->conn_id )
@@ -97,7 +97,7 @@ public function connect()
}
//Selecting database
- mysql_select_db($this->getDatabase(), $this->conn_id);
+ mysqli_select_db($this->conn_id,$this->getDatabase());
$this->state = self::OPEN;
//TODO onConnectSucess actions should be called from here
@@ -111,7 +111,7 @@ public function close()
if($this->conn_id && $this->state != self::CLOSED)
{
$this->state = self::CLOSED;
- mysql_close($this->conn_id);
+ mysqli_close($this->conn_id);
}
//$this->dispatchEvent('posClose', $this);
}
@@ -196,9 +196,9 @@ public function getErrorMsg()
$msg = '';
if($this->conn_id)
{
- $msg = mysql_error($this->conn_id);
+ $msg = mysqli_connect_error();
} else {
- $msg = mysql_error();
+ $msg = mysqli_connect_error();
}
return $msg;
}
@@ -214,7 +214,7 @@ public function getTables()
$list = array();
- while($row = mysql_fetch_row($rs))
+ while($row = mysqli_fetch_row($rs))
{
$list[] = $row[0];
}
@@ -232,7 +232,7 @@ public function getForeignKeys($tablename)
$fks = array();
$sql = sprintf("SHOW CREATE TABLE `%s`",$tablename);
$rs = $this->executeSQL($sql);
- $result = mysql_fetch_row($rs);
+ $result = mysqli_fetch_row($rs);
$result[0] = preg_replace("(\r|\n)",'\n', $result[0]);
$matches = array();
@@ -280,17 +280,17 @@ public function getServerInfo($type = null)
switch($type)
{
case self::CLIENT_VERSION:
- return mysql_get_client_info();
+ return mysqli_get_client_info();
break;
case self::HOST_INFO:
- return mysql_get_host_info($this->conn_id);
+ return mysqli_get_host_info($this->conn_id);
break;
case self::PROTOCOL_VERSION:
- return mysql_get_proto_info($this->conn_id);
+ return mysqli_get_proto_info($this->conn_id);
break;
case self::SERVER_VERSION:
default:
- return mysql_get_server_info($this->conn_id);
+ return mysqli_get_server_info($this->conn_id);
break;
}
return '';
@@ -305,7 +305,7 @@ public function describe($tablename)
$rs = $this->executeSQL( $sql );
$data = array();
- while($row = mysql_fetch_row($rs))
+ while($row = mysqli_fetch_row($rs))
{
$name = $row[0];
$type_native = $row[1];
@@ -345,7 +345,7 @@ public function executeSQL($sql)
{
//$this->dispatchEvent('preExecute', $this, $sql);
$this->connect();
- $rs = @mysql_query($sql, $this->conn_id);
+ $rs = @mysqli_query($sql, $this->conn_id);
if( ! $rs )
{
$msg = "[!Database error:!] " . $this->getErrorMsg();
@@ -361,7 +361,7 @@ public function executeSQL($sql)
public function unbuffExecuteSQL($sql) {
//$this->dispatchEvent('preExecute', $this, $sql);
$this->connect();
- $rs = @mysql_unbuffered_query($sql, $this->conn_id);
+ $rs = @mysqli_unbuffered_query($sql, $this->conn_id);
if( ! $rs )
{
$msg = "[!Database error:!] " . $this->getErrorMsg();
@@ -378,9 +378,9 @@ public function escape($str)
{
if($this->state == self::OPEN)
{
- return mysql_real_escape_string($str, $this->conn_id);
+ return mysqli_real_escape_string($str, $this->conn_id);
} else {
- return mysql_escape_string($str);
+ return mysqli_escape_string($str);
}
}
@@ -397,14 +397,14 @@ public function affected_rows()
{
if($this->state == self::OPEN)
{
- return mysql_affected_rows($this->conn_id);
+ return mysqli_affected_rows($this->conn_id);
}
//throw new PhpBURN_Exception() TODO CREATE EXCETION CLASS AND INPUT AN EXCEPTION HERE;
}
public function num_rows($rs)
{
- return mysql_num_rows($rs);
+ return mysqli_num_rows($rs);
}
public function random()
@@ -418,7 +418,7 @@ public function getEscapeChar()
}
public function fetch($rs) {
- return mysql_fetch_array($rs, $this->mode);
+ return mysqli_fetch_array($rs, $this->mode);
}
//Transactions
@@ -437,7 +437,7 @@ public function rollback($transactionID=null)
//Utils
public function last_id() {
- return mysql_insert_id($this->conn_id);
+ return mysqli_insert_id($this->conn_id);
}
public function __destruct() {
View
14 app/libs/Dialect/Dialect.php
@@ -455,12 +455,12 @@ public function saveRelationships($name = NULL) {
if($name == NULL) {
foreach ($this->getMap()->fields as $fieldCheck => $infos) {
if ($this->getModel()->getMap()->getRelationShip($fieldCheck) == true && $this->getModel()->$fieldCheck instanceof $infos['isRelationship']['foreignClass']) {
- $this->saveRelationship($infos, $fieldCheck);
+ return $this->saveRelationship($infos, $fieldCheck);
}
}
} else {
$infos = $this->getMap()->fields[$name];
- $this->saveRelationship($infos, $name);
+ return $this->saveRelationship($infos, $name);
}
}
@@ -474,16 +474,16 @@ protected function saveRelationship(&$infos, &$fieldCheck) {
case PhpBURN_Core::ONE_TO_ONE:
$this->getModel()->$fieldCheck->save();
$this->getModel()->getMap()->setFieldValue($infos['isRelationship']['thisKey'], $relModel->getMap()->getFieldValue($infos['isRelationship']['thisKey']));
- $this->getModel()->save();
+ $saved = $this->getModel()->save();
break;
case PhpBURN_Core::ONE_TO_MANY:
$relModel->getMap()->setFieldValue($infos['isRelationship']['relKey'], $this->getModel()->getMap()->getFieldValue($infos['isRelationship']['relKey']));
- $this->getModel()->$fieldCheck->save();
+ $saved = $this->getModel()->$fieldCheck->save();
break;
case PhpBURN_Core::MANY_TO_MANY:
- $this->getModel()->$fieldCheck->save();
+ $saved = $this->getModel()->$fieldCheck->save();
// SEARCH IF THE RELATIONSHIP ALREADY EXISTS
unset($sqlWHERE, $relationshipSQL, $rs);
@@ -516,13 +516,15 @@ protected function saveRelationship(&$infos, &$fieldCheck) {
$relModel->$relFieldName = $this->getModel()->$_name;
}
- $relModel->save();
+ $saved = $relModel->save();
}
}
// @TODO maybe this is a nice place to put save relationship data to reltable
break;
}
+
+ return $saved;
}
public function prepareInsert() {
View
2  app/libs/Model.php
@@ -632,7 +632,7 @@ public function save() {
}
public function saveRelationship($name) {
- $this->getDialect()->saveRelationships($name);
+ return $this->getDialect()->saveRelationships($name);
}
/**
Please sign in to comment.
Something went wrong with that request. Please try again.