Started "get" method of query builder
, added "quote_ident" method to db classes
This commit is contained in:
parent
955537cdb7
commit
ab6965cda6
@ -147,6 +147,22 @@ abstract class DB_PDO extends PDO {
|
||||
echo "Error: <pre>{$info[0]}:{$info[1]}\n{$info[2]}</pre>";
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Surrounds the string with the databases identifier escape characters
|
||||
*
|
||||
* @param string $ident
|
||||
* @return string
|
||||
*/
|
||||
public function quote_ident($ident)
|
||||
{
|
||||
// Split each identifier by the period
|
||||
$hiers = explode('.', $ident);
|
||||
|
||||
return '"'.implode('"."', $hiers).'"';
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
@ -196,7 +212,7 @@ abstract class DB_PDO extends PDO {
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
abstract public function backup_data();
|
||||
abstract public function backup_data();
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
@ -234,7 +250,5 @@ abstract class DB_SQL {
|
||||
* @return string
|
||||
*/
|
||||
abstract public function limit($sql, $limit, $offset);
|
||||
|
||||
|
||||
}
|
||||
// End of db_pdo.php
|
@ -18,6 +18,8 @@
|
||||
*/
|
||||
class Query_Builder {
|
||||
|
||||
private $table,
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
@ -70,4 +72,22 @@ class Query_Builder {
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Select and retrieve all records from the current table, and/or
|
||||
* execute current compiled query
|
||||
*
|
||||
* @param $table
|
||||
* @param int $limit
|
||||
* @param int $offset
|
||||
* @return object
|
||||
*/
|
||||
public function get($table='', $limit=FALSE, $offset=FALSE)
|
||||
{
|
||||
if ( ! empty($table) && $limit === FALSE && $offset === FALSE)
|
||||
{
|
||||
return $this->query('SELECT * FROM ' . $this->quote_ident($table));
|
||||
}
|
||||
}
|
||||
}
|
@ -128,5 +128,21 @@ class MySQL extends DB_PDO {
|
||||
// @todo Implement Backup function
|
||||
return '';
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Surrounds the string with the databases identifier escape characters
|
||||
*
|
||||
* @param string $ident
|
||||
* @return string
|
||||
*/
|
||||
public function quote_ident($ident)
|
||||
{
|
||||
// Split each identifier by the period
|
||||
$hiers = explode('.', $ident);
|
||||
|
||||
return '`'.implode('`.`', $hiers).'`';
|
||||
}
|
||||
}
|
||||
//End of mysql.php
|
Loading…
Reference in New Issue
Block a user