コード例 #1
0
 protected function _processSearch()
 {
     $class = $this->_getSearchClass();
     $table = DBObject::stGetTableName($class);
     $fieldId = $class::stGetFieldConfigFiltered(array("identifier" => true));
     $select = "SELECT {$this->fields} FROM {$table}";
     $where = "";
     foreach ($this->filters as $field => $filter) {
         $field = DBObject::stObjFieldToDBField($field);
         $op = $filter[0];
         if (is_array($filter[1])) {
             $whereField = "(";
             foreach ($filter[1] as $value) {
                 // TODO soporte para OR ?
                 $whereField = $whereField . "'" . $value . "'" . " AND ";
             }
             $whereField = substr($whereField, 0, -5) . ")";
         } else {
             $whereField = "'" . $filter[1] . "'";
         }
         $where = $where . $field . " " . $op . " " . $whereField . " AND ";
     }
     if ($where != "") {
         $select = $select . " WHERE " . substr($where, 0, -5);
     }
     $offset = ($this->page - 1) * $this->limit;
     $select = $select . " LIMIT {$offset},{$this->limit}";
     $mysqlParams = static::_stGetMySQLParams();
     $search = DBMySQLConnection::stVirtualConstructor($mysqlParams)->query($select);
     // Anotamos los resultados
     $this->count = $search->num_rows;
     // Guardamos la búsqueda
     $this->search = $search;
 }
コード例 #2
0
 private function _login()
 {
     // Permitimos el id y el email
     if (User::stExists(array("idUser" => $this->user))) {
         $query = "SELECT password from " . User::$table . " where id_user="******"SELECT id_user from " . User::$table . " where id_user="******"email" => $this->user))) {
             $query = "SELECT password from " . User::$table . " where email='" . $this->user . "'";
             $queryId = "SELECT id_user from " . User::$table . " where email='" . $this->user . "'";
         } else {
             $this->_setError("USER_DONT_EXIST", "User {$this->user} dont exist");
             return "";
         }
     }
     // TODO llevar password a datatype
     $res = DBMySQLConnection::stVirtualConstructor(User::$table)->select($query);
     if (is_null($res)) {
         $this->_setError("USER_DONT_EXIST", "User {$this->user} dont exist");
         return "";
     }
     if ($res["password"] == $this->password) {
         return array("idUser" => (int) DBMySQLConnection::stVirtualConstructor(User::$table)->select($queryId)["id_user"]);
     }
     $this->_setError("PASS_DONT_MATCH", "Password dont match");
     return "";
 }
コード例 #3
0
 private function _createSchema()
 {
     $classes = $this->_getConfigClasses();
     foreach ($classes as $class => $config) {
         $table = $this->_getTableSchema($config, $class);
         echo $table . "\n";
         if (!$this->run) {
             continue;
         }
         if (!DBMySQLConnection::stVirtualConstructor()->query($table)) {
             // TODO warning
             return false;
         }
     }
     return true;
 }
コード例 #4
0
ファイル: DBObject.php プロジェクト: jilgue/ownWebAppServices
 protected function _delete()
 {
     $mysqlParams = static::_stGetMySQLParams();
     return (bool) DBMySQLConnection::stVirtualConstructor($mysqlParams)->deleteObj($this->_getObjectId());
 }
コード例 #5
0
 static function stGetConnection()
 {
     return DBMySQLConnection::stVirtualConstructor()->getLink();
 }