Remove more references, and update README
This commit is contained in:
parent
27318506d0
commit
b1624e2f95
22
README.md
22
README.md
@ -80,4 +80,24 @@ To retreive the results of a query, use the PDO method [fetch](http://php.net/ma
|
|||||||
|
|
||||||
$query = $db->get('table_name');
|
$query = $db->get('table_name');
|
||||||
|
|
||||||
$results = $query->fetchAll(PDO::FETCH_ASSOC);
|
$results = $query->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
|
|
||||||
|
### Inserting / Updating
|
||||||
|
|
||||||
|
An example of an insert query:
|
||||||
|
|
||||||
|
$query = $db->set('foo', 'bar')
|
||||||
|
->set('foobar', 'baz')
|
||||||
|
->where('foo !=', 'bar')
|
||||||
|
->insert('table');
|
||||||
|
|
||||||
|
An example of an update query:
|
||||||
|
|
||||||
|
$query = $db->set('foo', 'bar')
|
||||||
|
->set('foobar', 'baz')
|
||||||
|
->where('foo !=', 'bar')
|
||||||
|
->update('table');
|
||||||
|
|
||||||
|
The `set` method can also take an array as a paramater, instead of setting individual values.
|
||||||
|
|
||||||
|
@ -446,6 +446,7 @@ abstract class DB_PDO extends PDO {
|
|||||||
/**
|
/**
|
||||||
* Return the number of rows returned for a SELECT query
|
* Return the number of rows returned for a SELECT query
|
||||||
*
|
*
|
||||||
|
* @see http://us3.php.net/manual/en/pdostatement.rowcount.php#87110
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function num_rows()
|
public function num_rows()
|
||||||
|
@ -311,7 +311,7 @@ class Query_Builder {
|
|||||||
$fields_array = array_map('trim', $fields_array);
|
$fields_array = array_map('trim', $fields_array);
|
||||||
|
|
||||||
// Split on 'As'
|
// Split on 'As'
|
||||||
foreach ($fields_array as $key => &$field)
|
foreach ($fields_array as $key => $field)
|
||||||
{
|
{
|
||||||
if (stripos($field, 'as') !== FALSE)
|
if (stripos($field, 'as') !== FALSE)
|
||||||
{
|
{
|
||||||
@ -586,7 +586,7 @@ class Query_Builder {
|
|||||||
$where = $this->_where($key, $val);
|
$where = $this->_where($key, $val);
|
||||||
|
|
||||||
// Create key/value placeholders
|
// Create key/value placeholders
|
||||||
foreach($where as $f => &$val)
|
foreach($where as $f => $val)
|
||||||
{
|
{
|
||||||
// Split each key by spaces, in case there
|
// Split each key by spaces, in case there
|
||||||
// is an operator such as >, <, !=, etc.
|
// is an operator such as >, <, !=, etc.
|
||||||
@ -659,7 +659,7 @@ class Query_Builder {
|
|||||||
// Array or object, loop through and add to the where array
|
// Array or object, loop through and add to the where array
|
||||||
elseif ( ! is_scalar($key))
|
elseif ( ! is_scalar($key))
|
||||||
{
|
{
|
||||||
foreach($key as $k => &$v)
|
foreach($key as $k => $v)
|
||||||
{
|
{
|
||||||
$where[$k] = $v;
|
$where[$k] = $v;
|
||||||
$this->values[] = $v;
|
$this->values[] = $v;
|
||||||
@ -684,7 +684,7 @@ class Query_Builder {
|
|||||||
$where = $this->_where($key, $val);
|
$where = $this->_where($key, $val);
|
||||||
|
|
||||||
// Create key/value placeholders
|
// Create key/value placeholders
|
||||||
foreach($where as $f => &$val)
|
foreach($where as $f => $val)
|
||||||
{
|
{
|
||||||
// Split each key by spaces, in case there
|
// Split each key by spaces, in case there
|
||||||
// is an operator such as >, <, !=, etc.
|
// is an operator such as >, <, !=, etc.
|
||||||
@ -846,7 +846,7 @@ class Query_Builder {
|
|||||||
// Object or array
|
// Object or array
|
||||||
elseif ( ! is_scalar($key))
|
elseif ( ! is_scalar($key))
|
||||||
{
|
{
|
||||||
foreach($key as $k => &$v)
|
foreach($key as $k => $v)
|
||||||
{
|
{
|
||||||
$this->set_array_keys[] = $k;
|
$this->set_array_keys[] = $k;
|
||||||
$this->values[] = $v;
|
$this->values[] = $v;
|
||||||
@ -954,7 +954,7 @@ class Query_Builder {
|
|||||||
$order_clauses = array();
|
$order_clauses = array();
|
||||||
|
|
||||||
// Flatten key/val pairs into an array of space-separated pairs
|
// Flatten key/val pairs into an array of space-separated pairs
|
||||||
foreach($this->order_array as $k => &$v)
|
foreach($this->order_array as $k => $v)
|
||||||
{
|
{
|
||||||
$order_clauses[] = $k . ' ' . strtoupper($v);
|
$order_clauses[] = $k . ' ' . strtoupper($v);
|
||||||
}
|
}
|
||||||
@ -1279,15 +1279,7 @@ class Query_Builder {
|
|||||||
$this->from($table);
|
$this->from($table);
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = $this->_compile();
|
return $this->_get_compile('select', $table, $reset);
|
||||||
|
|
||||||
// Reset the query builder for the next query
|
|
||||||
if ($reset)
|
|
||||||
{
|
|
||||||
$this->reset_query();
|
|
||||||
}
|
|
||||||
|
|
||||||
return $sql;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------------
|
// --------------------------------------------------------------------------
|
||||||
@ -1301,15 +1293,7 @@ class Query_Builder {
|
|||||||
*/
|
*/
|
||||||
public function get_compiled_insert($table, $reset=TRUE)
|
public function get_compiled_insert($table, $reset=TRUE)
|
||||||
{
|
{
|
||||||
$sql = $this->_compile("insert", $table);
|
return $this->_get_compile('insert', $table, $reset);
|
||||||
|
|
||||||
// Reset the query builder for the next query
|
|
||||||
if ($reset)
|
|
||||||
{
|
|
||||||
$this->reset_query();
|
|
||||||
}
|
|
||||||
|
|
||||||
return $sql;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------------
|
// --------------------------------------------------------------------------
|
||||||
@ -1323,15 +1307,7 @@ class Query_Builder {
|
|||||||
*/
|
*/
|
||||||
public function get_compiled_update($table='', $reset=TRUE)
|
public function get_compiled_update($table='', $reset=TRUE)
|
||||||
{
|
{
|
||||||
$sql = $this->_compile('update', $table);
|
return $this->_get_compile('update', $table, $reset);
|
||||||
|
|
||||||
// Reset the query builder for the next query
|
|
||||||
if ($reset)
|
|
||||||
{
|
|
||||||
$this->reset_query();
|
|
||||||
}
|
|
||||||
|
|
||||||
return $sql;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------------
|
// --------------------------------------------------------------------------
|
||||||
@ -1345,7 +1321,22 @@ class Query_Builder {
|
|||||||
*/
|
*/
|
||||||
public function get_compiled_delete($table="", $reset=TRUE)
|
public function get_compiled_delete($table="", $reset=TRUE)
|
||||||
{
|
{
|
||||||
$sql = $this->_compile("delete", $table);
|
return $this->_get_compile('delete', $table, $reset);
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper function for returning sql strings
|
||||||
|
*
|
||||||
|
* @param string $type
|
||||||
|
* @param string $table
|
||||||
|
* @param bool
|
||||||
|
* @resturn string
|
||||||
|
*/
|
||||||
|
protected function _get_compiled($type, $table, $reset)
|
||||||
|
{
|
||||||
|
$sql = $this->_compile($type, $table);
|
||||||
|
|
||||||
// Reset the query builder for the next query
|
// Reset the query builder for the next query
|
||||||
if ($reset)
|
if ($reset)
|
||||||
@ -1463,7 +1454,7 @@ class Query_Builder {
|
|||||||
// Set the where string
|
// Set the where string
|
||||||
if ( ! empty($this->query_map))
|
if ( ! empty($this->query_map))
|
||||||
{
|
{
|
||||||
foreach($this->query_map as &$q)
|
foreach($this->query_map as $q)
|
||||||
{
|
{
|
||||||
$sql .= $q['conjunction'] . $q['string'];
|
$sql .= $q['conjunction'] . $q['string'];
|
||||||
}
|
}
|
||||||
@ -1478,7 +1469,7 @@ class Query_Builder {
|
|||||||
// Set the having string
|
// Set the having string
|
||||||
if ( ! empty($this->having_map))
|
if ( ! empty($this->having_map))
|
||||||
{
|
{
|
||||||
foreach($this->having_map as &$h)
|
foreach($this->having_map as $h)
|
||||||
{
|
{
|
||||||
$sql .= $h['conjunction'] . $h['string'];
|
$sql .= $h['conjunction'] . $h['string'];
|
||||||
}
|
}
|
||||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user