| Previous CloneSet | Next CloneSet | Back to Main Report |
| Clone Mass | Clones in CloneSet | Parameter Count | Clone Similarity | Syntax Category [Sequence Length] |
|---|---|---|---|---|
| 339 | 2 | 6 | 0.996 | class_member_list[16] |
| Clone Abstraction | Parameter Bindings |
| Clone Instance (Click to see clone) | Line Count | Source Line | Source File |
|---|---|---|---|
| 1 | 339 | 342 | libraries/joomla/database/database/mysql.php |
| 2 | 339 | 358 | libraries/joomla/database/database/mysqli.php |
| ||||
/**
* This method loads the first field of the first row returned by the query.
*
* @access public
* @return The value returned in the query or null if the query failed.
*/
public
function loadResult() {
if (!($cur= $this->query())) {
return NULL;
}
$ret= NULL;
if ($row= mysql_fetch_row($cur)) {
$ret= $row[0];
}
mysql_free_result($cur);
return $ret;
}
/**
* Load an array of single field results into an array
*
* @access public
*/
public
function loadResultArray($numinarray= 0) {
if (!($cur= $this->query())) {
return NULL;
}
$array= array();
while ($row= mysql_fetch_row($cur)) {
$array[]= $row[$numinarray];
}
mysql_free_result($cur);
return $array;
}
/**
* Fetch a result row as an associative array
*
* @access public
* @return array
*/
public
function loadAssoc() {
if (!($cur= $this->query())) {
return NULL;
}
$ret= NULL;
if ($array= mysql_fetch_assoc($cur)) {
$ret= $array;
}
mysql_free_result($cur);
return $ret;
}
/**
* Load a assoc list of database rows
*
* @access public
* @param string The field name of a primary key
* @return array If <var>key</var> is empty as sequential list of returned records.
*/
public
function loadAssocList($key='') {
if (!($cur= $this->query())) {
return NULL;
}
$array= array();
while ($row= mysql_fetch_assoc($cur)) {
if ($key) {
$array[$row[$key]]= $row;
}
else {
$array[]= $row;
}
}
mysql_free_result($cur);
return $array;
}
/**
* This global function loads the first row of a query into an object
*
* @access public
* @return object
*/
public
function loadObject() {
if (!($cur= $this->query())) {
return NULL;
}
$ret= NULL;
if ($object= mysql_fetch_object($cur)) {
$ret= $object;
}
mysql_free_result($cur);
return $ret;
}
/**
* Load a list of database objects
*
* If <var>key</var> is not empty then the returned array is indexed by the value
* the database key. Returns <var>null</var> if the query fails.
*
* @access public
* @param string The field name of a primary key
* @return array If <var>key</var> is empty as sequential list of returned records.
*/
public
function loadObjectList($key='') {
if (!($cur= $this->query())) {
return NULL;
}
$array= array();
while ($row= mysql_fetch_object($cur)) {
if ($key) {
$array[$row->$key]= $row;
}
else {
$array[]= $row;
}
}
mysql_free_result($cur);
return $array;
}
/**
* Description
*
* @access public
* @return The first row of the query.
*/
public
function loadRow() {
if (!($cur= $this->query())) {
return NULL;
}
$ret= NULL;
if ($row= mysql_fetch_row($cur)) {
$ret= $row;
}
mysql_free_result($cur);
return $ret;
}
/**
* Load a list of database rows (numeric column indexing)
*
* @access public
* @param string The field name of a primary key
* @return array If <var>key</var> is empty as sequential list of returned records.
* If <var>key</var> is not empty then the returned array is indexed by the value
* the database key. Returns <var>null</var> if the query fails.
*/
public
function loadRowList($key=NULL) {
if (!($cur= $this->query())) {
return NULL;
}
$array= array();
while ($row= mysql_fetch_row($cur)) {
if ($key !== NULL) {
$array[$row[$key]]= $row;
}
else {
$array[]= $row;
}
}
mysql_free_result($cur);
return $array;
}
/**
* Inserts a row into a table based on an objects properties
*
* @access public
* @param string The name of the table
* @param object An object whose properties match table fields
* @param string The name of the primary key. If provided the object property is updated.
*/
public
function insertObject($table, &$object, $keyName= NULL) {
$fmtsql= 'INSERT INTO '
. $this->nameQuote($table)
. ' (%s) VALUES (%s) ';
$fields= array();
foreach (get_object_vars($object) as $k => $v)
{
if (is_array($v) or is_object($v) or $v === NULL) {
continue;
}
if ($k[0] == '_') { // internal field
continue;
}
$fields[]= $this->nameQuote($k);
$values[]= $this->isQuoted($k)
? $this->Quote($v)
: (int) $v;
}
$this->setQuery(sprintf($fmtsql, implode(",", $fields), implode(",", $values)));
if (!$this->query()) {
return FALSE;
}
$id= $this->insertid();
if ($keyName
&& $id) {
$object->$keyName= $id;
}
return TRUE;
}
/**
* Description
*
* @access public
* @param [type] $updateNulls
*/
public
function updateObject($table, &$object, $keyName, $updateNulls=TRUE) {
$fmtsql= 'UPDATE '
. $this->nameQuote($table)
. ' SET %s WHERE %s';
$tmp= array();
foreach (get_object_vars($object) as $k => $v)
{
if (is_array($v) or is_object($v) or $k[0] == '_') { // internal or NA field
continue;
}
if ($k == $keyName) { // PK not to be updated
$where= $keyName
. '='
. $this->Quote($v);
continue;
}
if ($v === NULL)
{
if ($updateNulls) {
$val= 'NULL';
}
else {
continue;
}
}
else {
$val= $this->isQuoted($k)
? $this->Quote($v)
: (int) $v;
}
$tmp[]= $this->nameQuote($k)
. '='
. $val;
}
$this->setQuery(sprintf($fmtsql, implode(",", $tmp), $where));
return $this->query();
}
/**
* Description
*
* @access public
*/
public
function insertid() {
return mysql_insert_id($this->_resource);
}
/**
* Description
*
* @access public
*/
public
function getVersion() {
return mysql_get_server_info($this->_resource);
}
/**
* Assumes database collation in use by sampling one text field in one table
*
* @access public
* @return string Collation in use
*/
public
function getCollation() {
if ($this->hasUTF()) {
$this->setQuery('SHOW FULL COLUMNS FROM #__content');
$array= $this->loadAssocList();
return $array['4']['Collation'];
}
else {
return "N/A (mySQL < 4.1.2)";
}
}
/**
* Description
*
* @access public
* @return array A list of all the tables in the database
*/
public
function getTableList() {
$this->setQuery('SHOW TABLES');
return $this->loadResultArray();
}
/**
* Shows the CREATE TABLE statement that creates the given tables
*
* @access public
* @param array|string A table name or a list of table names
* @return array A list the create SQL for the tables
*/
public
function getTableCreate($tables) {
settype($tables, 'array'); //force to array
$result= array();
foreach ($tables as $tblval) {
$this->setQuery('SHOW CREATE table '
. $this->getEscaped($tblval));
$rows= $this->loadRowList();
foreach ($rows as $row) {
$result[$tblval]= $row[1];
}
}
return $result;
}
/**
* Retrieves information about the given tables
*
* @access public
* @param array|string A table name or a list of table names
* @param boolean Only return field types, default true
* @return array An array of fields by table
*/
public
function getTableFields($tables, $typeonly= TRUE) {
settype($tables, 'array'); //force to array
$result= array();
foreach ($tables as $tblval)
{
$this->setQuery('SHOW FIELDS FROM '
. $tblval);
$fields= $this->loadObjectList();
if ($typeonly)
{
foreach ($fields as $field) {
$result[$tblval][$field->Field ]= preg_replace("/[(0-9)]/",'', $field->Type);
}
}
else
{
foreach ($fields as $field) {
$result[$tblval][$field->Field ]= $field;
}
}
}
return $result;
}
|
| ||||
/**
* This method loads the first field of the first row returned by the query.
*
* @access public
* @return The value returned in the query or null if the query failed.
*/
public
function loadResult() {
if (!($cur= $this->query())) {
return NULL;
}
$ret= NULL;
if ($row= mysqli_fetch_row($cur)) {
$ret= $row[0];
}
mysqli_free_result($cur);
return $ret;
}
/**
* Load an array of single field results into an array
*
* @access public
*/
public
function loadResultArray($numinarray= 0) {
if (!($cur= $this->query())) {
return NULL;
}
$array= array();
while ($row= mysqli_fetch_row($cur)) {
$array[]= $row[$numinarray];
}
mysqli_free_result($cur);
return $array;
}
/**
* Fetch a result row as an associative array
*
* @access public
* @return array
*/
public
function loadAssoc() {
if (!($cur= $this->query())) {
return NULL;
}
$ret= NULL;
if ($array= mysqli_fetch_assoc($cur)) {
$ret= $array;
}
mysqli_free_result($cur);
return $ret;
}
/**
* Load a assoc list of database rows
*
* @access public
* @param string The field name of a primary key
* @return array If <var>key</var> is empty as sequential list of returned records.
*/
public
function loadAssocList($key='') {
if (!($cur= $this->query())) {
return NULL;
}
$array= array();
while ($row= mysqli_fetch_assoc($cur)) {
if ($key) {
$array[$row[$key]]= $row;
}
else {
$array[]= $row;
}
}
mysqli_free_result($cur);
return $array;
}
/**
* This global function loads the first row of a query into an object
*
* @access public
* @return object
*/
public
function loadObject() {
if (!($cur= $this->query())) {
return NULL;
}
$ret= NULL;
if ($object= mysqli_fetch_object($cur)) {
$ret= $object;
}
mysqli_free_result($cur);
return $ret;
}
/**
* Load a list of database objects
*
* If <var>key</var> is not empty then the returned array is indexed by the value
* the database key. Returns <var>null</var> if the query fails.
*
* @access public
* @param string The field name of a primary key
* @return array If <var>key</var> is empty as sequential list of returned records.
*/
public
function loadObjectList($key='') {
if (!($cur= $this->query())) {
return NULL;
}
$array= array();
while ($row= mysqli_fetch_object($cur)) {
if ($key) {
$array[$row->$key]= $row;
}
else {
$array[]= $row;
}
}
mysqli_free_result($cur);
return $array;
}
/**
* Description
*
* @access public
* @return The first row of the query.
*/
public
function loadRow() {
if (!($cur= $this->query())) {
return NULL;
}
$ret= NULL;
if ($row= mysqli_fetch_row($cur)) {
$ret= $row;
}
mysqli_free_result($cur);
return $ret;
}
/**
* Load a list of database rows (numeric column indexing)
*
* If <var>key</var> is not empty then the returned array is indexed by the value
* the database key. Returns <var>null</var> if the query fails.
*
* @access public
* @param string The field name of a primary key
* @return array If <var>key</var> is empty as sequential list of returned records.
*/
public
function loadRowList($key=NULL) {
if (!($cur= $this->query())) {
return NULL;
}
$array= array();
while ($row= mysqli_fetch_row($cur)) {
if ($key !== NULL) {
$array[$row[$key]]= $row;
}
else {
$array[]= $row;
}
}
mysqli_free_result($cur);
return $array;
}
/**
* Inserts a row into a table based on an objects properties
*
* @access public
* @param string The name of the table
* @param object An object whose properties match table fields
* @param string The name of the primary key. If provided the object property is updated.
*/
public
function insertObject($table, &$object, $keyName= NULL) {
$fmtsql= 'INSERT INTO '
. $this->nameQuote($table)
. ' (%s) VALUES (%s) ';
$fields= array();
foreach (get_object_vars($object) as $k => $v) {
if (is_array($v) or is_object($v) or $v === NULL) {
continue;
}
if ($k[0] == '_') { // internal field
continue;
}
$fields[]= $this->nameQuote($k);
$values[]= $this->isQuoted($k)
? $this->Quote($v)
: (int) $v;
}
$this->setQuery(sprintf($fmtsql, implode(",", $fields), implode(",", $values)));
if (!$this->query()) {
return FALSE;
}
$id= $this->insertid();
if ($keyName
&& $id) {
$object->$keyName= $id;
}
return TRUE;
}
/**
* Description
*
* @access public
* @param [type] $updateNulls
*/
public
function updateObject($table, &$object, $keyName, $updateNulls=TRUE) {
$fmtsql= 'UPDATE '
. $this->nameQuote($table)
. ' SET %s WHERE %s';
$tmp= array();
foreach (get_object_vars($object) as $k => $v) {
if (is_array($v) or is_object($v) or $k[0] == '_') { // internal or NA field
continue;
}
if ($k == $keyName) { // PK not to be updated
$where= $keyName
. '='
. $this->Quote($v);
continue;
}
if ($v === NULL)
{
if ($updateNulls) {
$val= 'NULL';
}
else {
continue;
}
}
else {
$val= $this->isQuoted($k)
? $this->Quote($v)
: (int) $v;
}
$tmp[]= $this->nameQuote($k)
. '='
. $val;
}
$this->setQuery(sprintf($fmtsql, implode(",", $tmp), $where));
return $this->query();
}
/**
* Description
*
* @access public
*/
public
function insertid() {
return mysqli_insert_id($this->_resource);
}
/**
* Description
*
* @access public
*/
public
function getVersion() {
return mysqli_get_server_info($this->_resource);
}
/**
* Assumes database collation in use by sampling one text field in one table
*
* @access public
* @return string Collation in use
*/
public
function getCollation() {
if ($this->hasUTF()) {
$this->setQuery('SHOW FULL COLUMNS FROM #__content');
$array= $this->loadAssocList();
return $array['4']['Collation'];
}
else {
return "N/A (mySQL < 4.1.2)";
}
}
/**
* Description
*
* @access public
* @return array A list of all the tables in the database
*/
public
function getTableList() {
$this->setQuery('SHOW TABLES');
return $this->loadResultArray();
}
/**
* Shows the CREATE TABLE statement that creates the given tables
*
* @access public
* @param array|string A table name or a list of table names
* @return array A list the create SQL for the tables
*/
public
function getTableCreate($tables) {
settype($tables, 'array'); //force to array
$result= array();
foreach ($tables as $tblval)
{
$this->setQuery('SHOW CREATE table '
. $this->getEscaped($tblval));
$rows= $this->loadRowList();
foreach ($rows as $row) {
$result[$tblval]= $row[1];
}
}
return $result;
}
/**
* Retrieves information about the given tables
*
* @access public
* @param array|string A table name or a list of table names
* @param boolean Only return field types, default true
* @return array An array of fields by table
*/
public
function getTableFields($tables, $typeonly= TRUE) {
settype($tables, 'array'); //force to array
$result= array();
foreach ($tables as $tblval)
{
$this->setQuery('SHOW FIELDS FROM '
. $tblval);
$fields= $this->loadObjectList();
if ($typeonly)
{
foreach ($fields as $field) {
$result[$tblval][$field->Field ]= preg_replace("/[(0-9)]/",'', $field->Type);
}
}
else
{
foreach ($fields as $field) {
$result[$tblval][$field->Field ]= $field;
}
}
}
return $result;
}
|
| |||
/**
* This method loads the first field of the first row returned by the query.
*
* @access public
* @return The value returned in the query or null if the query failed.
*/
/**
* This method loads the first field of the first row returned by the query.
*
* @access public
* @return The value returned in the query or null if the query failed.
*/
public
function loadResult() {
if (!($cur=$this->query())) {
return NULL;
}
$ret=NULL;
if ($row= [[#variable490fea80]]($cur)) {
$ret=$row[0];
}
[[#variable1d612f60]]($cur);
return $ret;
}
/**
* Load an array of single field results into an array
*
* @access public
*/
/**
* Load an array of single field results into an array
*
* @access public
*/
public
function loadResultArray($numinarray=0) {
if (!($cur=$this->query())) {
return NULL;
}
$array=array();
while ($row= [[#variable490fea80]]($cur)) {
$array[]=$row[$numinarray];
}
[[#variable1d612f60]]($cur);
return $array;
}
/**
* Fetch a result row as an associative array
*
* @access public
* @return array
*/
/**
* Fetch a result row as an associative array
*
* @access public
* @return array
*/
public
function loadAssoc() {
if (!($cur=$this->query())) {
return NULL;
}
$ret=NULL;
if ($array= [[#variable490fe780]]($cur)) {
$ret=$array;
}
[[#variable1d612f60]]($cur);
return $ret;
}
/**
* Load a assoc list of database rows
*
* @access public
* @param string The field name of a primary key
* @return array If <var>key</var> is empty as sequential list of returned records.
*/
/**
* Load a assoc list of database rows
*
* @access public
* @param string The field name of a primary key
* @return array If <var>key</var> is empty as sequential list of returned records.
*/
public
function loadAssocList($key='') {
if (!($cur=$this->query())) {
return NULL;
}
$array=array();
while ($row= [[#variable490fe780]]($cur)) {
if ($key) {
$array[$row[$key]]=$row;
}
else {
$array[]=$row;
}
}
[[#variable1d612f60]]($cur);
return $array;
}
/**
* This global function loads the first row of a query into an object
*
* @access public
* @return object
*/
/**
* This global function loads the first row of a query into an object
*
* @access public
* @return object
*/
public
function loadObject() {
if (!($cur=$this->query())) {
return NULL;
}
$ret=NULL;
if ($object= [[#variable1c9d7440]]($cur)) {
$ret=$object;
}
[[#variable1d612f60]]($cur);
return $ret;
}
/**
* Load a list of database objects
*
* If <var>key</var> is not empty then the returned array is indexed by the value
* the database key. Returns <var>null</var> if the query fails.
*
* @access public
* @param string The field name of a primary key
* @return array If <var>key</var> is empty as sequential list of returned records.
*/
/**
* Load a list of database objects
*
* If <var>key</var> is not empty then the returned array is indexed by the value
* the database key. Returns <var>null</var> if the query fails.
*
* @access public
* @param string The field name of a primary key
* @return array If <var>key</var> is empty as sequential list of returned records.
*/
public
function loadObjectList($key='') {
if (!($cur=$this->query())) {
return NULL;
}
$array=array();
while ($row= [[#variable1c9d7440]]($cur)) {
if ($key) {
$array[$row->$key]=$row;
}
else {
$array[]=$row;
}
}
[[#variable1d612f60]]($cur);
return $array;
}
/**
* Description
*
* @access public
* @return The first row of the query.
*/
/**
* Description
*
* @access public
* @return The first row of the query.
*/
public
function loadRow() {
if (!($cur=$this->query())) {
return NULL;
}
$ret=NULL;
if ($row= [[#variable490fea80]]($cur)) {
$ret=$row;
}
[[#variable1d612f60]]($cur);
return $ret;
}
/**
* Load a list of database rows (numeric column indexing)
*
* @access public
* @param string The field name of a primary key
* @return array If <var>key</var> is empty as sequential list of returned records.
* If <var>key</var> is not empty then the returned array is indexed by the value
* the database key. Returns <var>null</var> if the query fails.
*/
/**
* Load a list of database rows (numeric column indexing)
*
* If <var>key</var> is not empty then the returned array is indexed by the value
* the database key. Returns <var>null</var> if the query fails.
*
* @access public
* @param string The field name of a primary key
* @return array If <var>key</var> is empty as sequential list of returned records.
*/
public
function loadRowList($key=NULL) {
if (!($cur=$this->query())) {
return NULL;
}
$array=array();
while ($row= [[#variable490fea80]]($cur)) {
if ($key !== NULL) {
$array[$row[$key]]=$row;
}
else {
$array[]=$row;
}
}
[[#variable1d612f60]]($cur);
return $array;
}
/**
* Inserts a row into a table based on an objects properties
*
* @access public
* @param string The name of the table
* @param object An object whose properties match table fields
* @param string The name of the primary key. If provided the object property is updated.
*/
/**
* Inserts a row into a table based on an objects properties
*
* @access public
* @param string The name of the table
* @param object An object whose properties match table fields
* @param string The name of the primary key. If provided the object property is updated.
*/
public
function insertObject($table,&$object,$keyName=NULL) {
$fmtsql='INSERT INTO '
. $this->nameQuote($table)
. ' (%s) VALUES (%s) ';
$fields=array();
foreach (get_object_vars($object) as $k => $v) {
if (is_array($v) or is_object($v) or $v === NULL) {
continue;
}
if ($k[0] == '_') { // internal field
continue;
}
$fields[]=$this->nameQuote($k);
$values[]=$this->isQuoted($k)
? $this->Quote($v)
: (int) $v;
}
$this->setQuery(sprintf($fmtsql,implode(",",$fields),implode(",",$values)));
if (!$this->query()) {
return FALSE;
}
$id=$this->insertid();
if ($keyName
&& $id) {
$object->$keyName=$id;
}
return TRUE;
}
/**
* Description
*
* @access public
* @param [type] $updateNulls
*/
public
function updateObject($table,&$object,$keyName,$updateNulls=TRUE) {
$fmtsql='UPDATE '
. $this->nameQuote($table)
. ' SET %s WHERE %s';
$tmp=array();
foreach (get_object_vars($object) as $k => $v) {
if (is_array($v) or is_object($v) or $k[0] == '_') { // internal or NA field
continue;
}
if ($k == $keyName) { // PK not to be updated
$where=$keyName
. '='
. $this->Quote($v);
continue;
}
if ($v === NULL) {
if ($updateNulls) {
$val='NULL';
}
else {
continue;
}
}
else {
$val=$this->isQuoted($k)
? $this->Quote($v)
: (int) $v;
}
$tmp[]=$this->nameQuote($k)
. '='
. $val;
}
$this->setQuery(sprintf($fmtsql,implode(",",$tmp),$where));
return $this->query();
}
/**
* Description
*
* @access public
*/
public
function insertid() {
return [[#variable1cf919c0]]($this->_resource);
}
/**
* Description
*
* @access public
*/
public
function getVersion() {
return [[#variable490fe6e0]]($this->_resource);
}
/**
* Assumes database collation in use by sampling one text field in one table
*
* @access public
* @return string Collation in use
*/
/**
* Assumes database collation in use by sampling one text field in one table
*
* @access public
* @return string Collation in use
*/
public
function getCollation() {
if ($this->hasUTF()) {
$this->setQuery('SHOW FULL COLUMNS FROM #__content');
$array=$this->loadAssocList();
return $array['4']['Collation'];
}
else {
return "N/A (mySQL < 4.1.2)";
}
}
/**
* Description
*
* @access public
* @return array A list of all the tables in the database
*/
/**
* Description
*
* @access public
* @return array A list of all the tables in the database
*/
public
function getTableList() {
$this->setQuery('SHOW TABLES');
return $this->loadResultArray();
}
/**
* Shows the CREATE TABLE statement that creates the given tables
*
* @access public
* @param array|string A table name or a list of table names
* @return array A list the create SQL for the tables
*/
public
function getTableCreate($tables) {
settype($tables,'array'); //force to array
$result=array();
foreach ($tables as $tblval) {
$this->setQuery('SHOW CREATE table '
. $this->getEscaped($tblval));
$rows=$this->loadRowList();
foreach ($rows as $row) {
$result[$tblval]=$row[1];
}
}
return $result;
}
/**
* Retrieves information about the given tables
*
* @access public
* @param array|string A table name or a list of table names
* @param boolean Only return field types, default true
* @return array An array of fields by table
*/
public
function getTableFields($tables,$typeonly=TRUE) {
settype($tables,'array'); //force to array
$result=array();
foreach ($tables as $tblval) {
$this->setQuery('SHOW FIELDS FROM '
. $tblval);
$fields=$this->loadObjectList();
if ($typeonly) {
foreach ($fields as $field) {
$result[$tblval][$field->Field ]=preg_replace("/[(0-9)]/",'',$field->Type);
}
}
else {
foreach ($fields as $field) {
$result[$tblval][$field->Field ]=$field;
}
}
}
return $result;
}
|
| CloneAbstraction |
| Parameter Index | Clone Instance | Parameter Name | Value |
|---|---|---|---|
| 1 | 1 | [[#490fea80]] | mysql_fetch_row |
| 1 | 2 | [[#490fea80]] | mysqli_fetch_row |
| 2 | 1 | [[#1d612f60]] | mysql_free_result |
| 2 | 2 | [[#1d612f60]] | mysqli_free_result |
| 3 | 1 | [[#490fe780]] | mysql_fetch_assoc |
| 3 | 2 | [[#490fe780]] | mysqli_fetch_assoc |
| 4 | 1 | [[#1c9d7440]] | mysql_fetch_object |
| 4 | 2 | [[#1c9d7440]] | mysqli_fetch_object |
| 5 | 1 | [[#1cf919c0]] | mysql_insert_id |
| 5 | 2 | [[#1cf919c0]] | mysqli_insert_id |
| 6 | 1 | [[#490fe6e0]] | mysql_get_server_info |
| 6 | 2 | [[#490fe6e0]] | mysqli_get_server_info |