ice framework documentation ice doc v1.10.1
Methods
  • getId() : void
  • getType() : void
  • getClient() : void
  • getDriverName() : void
  • __construct(string $dsn, string $user, string $password, array $options) : void
    Instantiate pdo connection.
  • getIdValue(variable $id) : int
    Get the id value.
  • getDateTime(variable $value, variable $model) : void
    Get a date time object.
  • findOne(string $from, variable $filters, array $options, array $fields) : void
    Find one row that match criteria.
  • find(string $from, variable $filters, array $options, array $fields) : void
    Find all records that match criteria.
  • count(string $from, variable $filters) : int
    Count rows that match criteria.
  • where(variable $filters, array $values, array $options) : array
    Prepare SQL WHERE condition.
  • select(string $from, variable $filters, array $options, array $fields) : void
    SELECT record(s) that match criteria.
  • insert(string $from, array $fields) : void
    INSERT record into table.
  • update(string $from, variable $filters, array $fields) : void
    UPDATE records in the table.
  • delete(string $from, variable $filters) : void
    Remove records from the table.
  • query(string $sql, array $values, variable $obj) : void
    Query sql statement. execute the statement and populate into Model object:
  • getLastInsertId() : int
    Get last inserted ID.
  • getError() : void
    Get an error message.
Methods Details
  • public function getId()

  • public function getType()

  • public function getClient()

  • public function getDriverName()

  • public function __construct(string $dsn, string $user, string $password, array $options)

    Instantiate pdo connection.
  • public function getIdValue(variable $id)

    Get the id value.
  • public function getDateTime(variable $value, variable $model)

    Get a date time object.
  • public function findOne(string $from, variable $filters, array $options, array $fields)

    Find one row that match criteria.
    
          //SELECT x, y FROM users WHERE a=1 or b=2 ORDER BY a desc,b asc Limit 1
          $db->findOne("users", ["OR" => [["a" => 1], ["b" => 2]]], ["order" => ["a desc", "b asc"]], ["x","y"]);
         
  • public function find(string $from, variable $filters, array $options, array $fields)

    Find all records that match criteria.
    
          //SELECT FROM users WHERE a=1 and b="q"
          $db->find("users", ["a" => 1, "b" => "q"]);
         
          //SELECT FROM users WHERE age>33
          $db->find("users", ["age" => [">" => 33]]);
         
          //SELECT x, y FROM users WHERE a=1 or b=2 ORDER BY a desc,b asc
          $db->find("users", ["OR" => [["a" => 1], ["b" => 2]]], ["order" => ["a desc", "b asc"]], ["x","y"]);
         
  • public function count(string $from, variable $filters)

    Count rows that match criteria.
    
          //SELECT count() as total FROM users WHERE a=1
          $db->count("users", ["a" => 1]);
         
  • protected function where(variable $filters, array $values, array $options)

    Prepare SQL WHERE condition.
  • public function select(string $from, variable $filters, array $options, array $fields)

    SELECT record(s) that match criteria.
    
          // MySQL: SELECT FROM users WHERE a=1 or b=2 ORDER BY a desc,b asc LIMIT 10
          // MSSQL: SELECT TOP 10 FROM users WHERE a=1 or b=2 ORDER BY a desc,b asc
          $db->select("users", ["OR" => [["a" => 1], ["b" => 2]]], ["order" => ["a desc", "b asc"], "limit" => 10]);
         
          // MySQL: SELECT x, y FROM users WHERE a=1 or b=2 ORDER BY a desc,b asc LIMIT 10 offset 50
          // MSSQL: SELECT x, y FROM users WHERE a=1 or b=2 ORDER BY a desc,b asc offset 50 ROWS FETCH NEXT 10 ROWS ONLY
          $db->select("users", ["OR" => [["a" => 1], ["b" => 2]]], ["order" => ["a desc", "b asc"], "limit" => 10, "offset" => 50], ["x","y"]);
         
  • public function insert(string $from, array $fields)

    INSERT record into table.
    
          //INSERT INTO users (a,b) VALUES (1, 2)
          $db->insert("users", [["a" => 1], ["b" => 2]]);
         
  • public function update(string $from, variable $filters, array $fields)

    UPDATE records in the table.
    
          //UPDATE users SET a=1, b=2 WHERE id=10 OR foo="bar"
          $db->update("users", ["OR" => ["id" => 10, "foo" => "bar"]], [["a" => 1], ["b" => 2]]);
         
  • public function delete(string $from, variable $filters)

    Remove records from the table.
    
          //DELETE FROM users WHERE id=10 OR foo="bar"
          $db->delete("users", ["OR" => ["id" => 10, "foo" => "bar"]]);
         
  • public function query(string $sql, array $values, variable $obj)

    Query sql statement. execute the statement and populate into Model object:
    
          //select from t where id=1
          $m = $this->db->query('select from t where id=:id', [':id' => 1], new stdClass);
         
          //select from t where id=1 OR foo='bar'
          $m = $this->db->query('select from t where id=? OR foo=?', [1, "bar"], '\Ice\Arr');
         
  • public function getLastInsertId()

    Get last inserted ID.
  • public function getError()

    Get an error message.