$this->table() now had parameter for auto-escaping #0
git-svn-id: svn+ssh://code.netmonsters.ru/svn/majestic/branches/evo@118 4cb57b5f-5bbd-dd11-951b-001d605cbbc5
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Класс модели данных
|
||||
*
|
||||
@ -39,7 +40,7 @@ abstract class Model
|
||||
*/
|
||||
public function getInsertId()
|
||||
{
|
||||
return $this->db->getInsertId($this->table(), $this->key);
|
||||
return $this->db->getInsertId($this->table(false), $this->key);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -66,8 +67,7 @@ abstract class Model
|
||||
*/
|
||||
public function get($id)
|
||||
{
|
||||
$sql = 'SELECT * FROM ' . $this->identify($this->table())
|
||||
. ' WHERE ' . $this->identify($this->key) . '=' . (int) $id;
|
||||
$sql = 'SELECT * FROM ' . $this->table() . ' WHERE ' . $this->identify($this->key) . '=' . (int) $id;
|
||||
return $this->db->query($sql)->fetch();
|
||||
}
|
||||
|
||||
@ -94,7 +94,7 @@ abstract class Model
|
||||
*/
|
||||
public function insert($data)
|
||||
{
|
||||
if (! $this->db->insert($this->table(), $data)) {
|
||||
if (!$this->db->insert($this->table(false), $data)) {
|
||||
return false;
|
||||
}
|
||||
return $this->getInsertId();
|
||||
@ -107,7 +107,7 @@ abstract class Model
|
||||
*/
|
||||
public function update($data, $where)
|
||||
{
|
||||
return $this->db->update($this->table(), $data, $where);
|
||||
return $this->db->update($this->table(false), $data, $where);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -119,17 +119,18 @@ abstract class Model
|
||||
if (is_int($where)) {
|
||||
$where = $this->identify($this->key) . '=' . (int) $where;
|
||||
}
|
||||
return $this->db->delete($this->table(), $where);
|
||||
return $this->db->delete($this->table(false), $where);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $autoescape
|
||||
* @return string
|
||||
*/
|
||||
public function table()
|
||||
public function table($autoescape = true)
|
||||
{
|
||||
if (! $this->table) {
|
||||
if (!$this->table) {
|
||||
$this->table = substr(strtolower(get_class($this)), 0, -5/*strlen('Model')*/);
|
||||
}
|
||||
return $this->table;
|
||||
return $identify ? $this->identify($this->table) : $this->table;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user