Jump to content

[dx]

Members
  • Posts

    719
  • Joined

  • Last visited

About [dx]

  • Birthday 06/29/1988

Previous Fields

  • Languages
    HTML, CSS, PHP, SQL, Javascript, AJAX, jQuery

Profile Information

  • Location
    Bosnia & Herzegovina

Recent Profile Visitors

5,639 profile views

[dx]'s Achievements

Invested Member

Invested Member (3/7)

4

Reputation

  1. Hello after long time. How are you guys? I stuck with one problem about Promises. I'm working on service which collects data from some services and join them to object to output. My current code is like: var p1 = async_thenable_method(), p2 = async_thenable_method(), p3 = async_thenable_method(); Promise.resolve([ p1, p2, p3 ]).then(function® { ... }); That's quite easy but problem is that I have also one method which is dependency for one of them so i need wait for one promise to finish, and then take that data to another method. I tried to make Promise in promise but can't get it working. Which is right way to deal with this? Thanks.
  2. Hi, Long time ago since I was here. I'm trying to make auth option using token. I have middleware which connects to User model and check db and store data from User::where('token', $token)->first() to User's public var $user. So everything about it works fine, but now when I make some controller I want use that instance of model. If I add use App\User; it creates new instance of model, so my data from $user are set to null. How can I access old data? Best regards.
  3. Ingolme: http://www.bootply.com/SubWSDQsjr dsonesuk: http://www.bootply.com/qqc6UgSMrP Desktop is fine, but I need A C B order in mobile. Check images in attachment above.
  4. I'm trying but not successfully. With cols pushing/pulling it works if cols are in same row (like in example: col-3 and col-9), but for me is different.
  5. If you mean about pushing and pulling, yes I did. But can't find solution.
  6. Hello guys. In attachment you can find files / images how I need to make my design "desktop vs mobile". It can be done with pure CSS or any CSS framework. Last option I want is jQuery. Best regards.
  7. Hi guys, I'm making tasklist application. So this is my structure. Account.php class Account extends AppModel { public $hasAndBelongsToMany = array('Company'); } User can register multiples accounts, but also can be joined to multiple companies. Company.php class Company extends AppModel { public $hasAndBelongsToMany = array('Account'); public $hasMany = array('Project'); } Project.php class Project extends AppModel { public $belongsTo = array('Company'); public $hasMany = array('Task'); } Task.php class Task extends AppModel { public $belongsTo = array('Project');} I hope this all is clear. So what I want? I need to fetch all projects that are in relationship with me (with current ID logged in): class ProjectsController extends AppController { public function get() { $projects = $this->Project->Company->Account->find('all', array( 'conditions' => array('id' => 1) )); $this->set('content', $projects); $this->layout = 'ajax'; }} But for this query I'm getting this result: Array( [0] => Array ( [Account] => Array ( // data removed ) [Company] => Array ( [0] => Array ( // data removed ) [1] => Array ( // data removed ) ) )) This data is correct, I'm getting info about user, and 2 companies where user with id "1" is owner. Now only I need to get projects from companies where I'm employed. Could you give me right clue in which direction to move? Can this be done and how? What I'm missing. P.S. - There are data (projects) in database associated with this listed companies. Best regards.
  8. [dx]

    Problem using PDO

    Hi, For someone with same problem. In my case error reporting don't work but I found error. Problem was in query: $query = $db->prepare("INSERT INTO utakmice (domacin, gost, broj_kola) SELECT * FROM (SELECT ?, ?, ?) AS tmp WHERE NOT EXISTS (SELECT domacin, gost, broj_kola FROM utakmice WHERE domacin = ? AND gost = ? AND broj_kola = ?) LIMIT 1"); It seems that it can proceed with duplicated columns names. Like (SELECT 20, 20, 10). If params have same value it stops. So I found other way.
  9. [dx]

    Problem using PDO

    It outputs before calling execute(), but later nothing.
  10. [dx]

    Problem using PDO

    Nothing outputed with $query->errorInfo() It should insert data in db, but it won't execute.
  11. [dx]

    Problem using PDO

    It won't output anything if I use print_r($db->errorInfo()); just after $query->execute(); :S
  12. [dx]

    Problem using PDO

    Hi, I'm managing some script so I have problem inserting new data to dbase. Here's my connection: $config = array('host' => 'localhost','username' => 'xxxx','password' => 'xxxx','dbname' => 'xxxx','charset' => 'latin2');$db = new PDO('mysql:host=' . $config['host'] . ';dbname=' . $config['dbname'] .';charset=' . $config['charset'], $config['username'], $config['password']);$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); And this is piece of code which worked for me and I didn't changed anything it just stopped to work: for ($i = 0; $i < count($_POST['domacin']); $i++) {if (strlen($_POST['domacin'][$i]) > 0 and strlen($_POST['gost'][$i]) > 0):if ($_POST['domacin'][$i] != $_POST['gost'][$i]):$query = $db->prepare("INSERT INTO utakmice (domacin, gost, broj_kola) SELECT * FROM (SELECT ?, ?, ?) AS tmp WHERE NOT EXISTS (SELECT domacin, gost, broj_kola FROM utakmice WHERE domacin = ? AND gost = ? AND broj_kola = ?) LIMIT 1");$query->bindValue(1, $_POST['domacin'][$i]);$query->bindValue(2, $_POST['gost'][$i]);$query->bindValue(3, $_POST['kolo_broj']);$query->bindValue(4, $_POST['domacin'][$i]);$query->bindValue(5, $_POST['gost'][$i]);$query->bindValue(6, $_POST['kolo_broj']);$query->execute();endif;endif;} As you can see I'm getting $_POST['domacin'] and $_POST['gost'] with same number of items so it loops and store unique data. Can it be that dbase does not allow spam like? I'm really sure that it works becouse I used it before. This for adding sport matches, I added few rounds and it just stopped. Can you provide me a clue where I can search? Best regards.
  13. Problem was User Model's filename. It should be just User.php
  14. Hi, I'm new with cakePHP and trying to make form validation. It just won't validate... This is my code: // Users/test.ctpecho $this->Form->create(); echo $this->Form->input('firstname');echo $this->Form->end('Test'); // UsersController.phpclass UsersController extends AppController { public function test() { if ($this->request->is('post')) { $this->User->set($this->request->data); if ($this->User->validates()) { pr('no errors'); } else { pr($this->User->validationErrors); } } }} // UserModel.phpclass User extends AppModel { public $validate = array( 'firstname' => array( 'between' => array( 'rule' => array('between', 3, 50), 'message' => 'Firstname must be between 3 and 50 characters long.', ), 'notEmpty' => array( 'rule' => 'notEmpty', 'message' => 'You must provide first name!' ) ) );} Best regards!
×
×
  • Create New...