Jump to content

[dx]

Members
  • Posts

    719
  • Joined

  • Last visited

Everything posted by [dx]

  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!
  15. Hi dsonesuk, Thank your for reply. I tryed both, php generating and static html like value="something". I'm sure, checked twice, that it's double quotes correctly, and it's utf8.
  16. Even work on jsbin or jsfiddle, but not for me. Those value are just empty..
  17. Nothing special, few input fields in <form> ... </form>
  18. Hi, I'm trying make some form for user registration, and I have multiple checkboxes for categories. So I'm using: <input type="checkbox" name="category[]" value="category_1"> Category 1<input type="checkbox" name="category[]" value="category_2"> Category 2<input type="checkbox" name="category[]" value="category_3"> Category 3<input type="checkbox" name="category[]" value="category_4"> Category 4etc.. It's all in <form> tag. When I go to console, I can see only value attribute like: <input type="checkbox" name="category[]" value> Category 1 But if I go to view source, there's html as it should be. What can cause it? This is reason why I can't fetch data correctly with .serializeArray(). How to solve it?
  19. time() is changed every second with +1. 60 seconds in 1 minute 60 minutes in 1 hour 24 hours in 1 day So 60 x 60 x 24 = 86400 seconds in 1 day Hope you need it?
  20. [dx]

    ASP.NET

    Hi, Where to start with ASP.NET? What do I need? Only Windows server?
  21. Hi, I need to parse html tags from file but allow_url_fopen is disabled so I can't go via file_get_contents() to url, or curl, or sockets.. I have .php file which generates html preview in browser, but if I do file_get_contents(filename) I got copy of php file, not html tags.. Any suggestion what to do..
  22. Hi, In normal case, PHP functions are executed in high speeds, especially on high speed servers, line by line. But what if we have mysql connection (query) to remote server. $q = mysql_query("QUERY HERE"); // I guess there's some delay uppon connecting to remote mysql server if ($q) return 'something'; return 'something else'; So, since mysql_query() is function, and in normal case, PHP waits for function to execute, and store data to variable, and then goes next. So if we have some delay for connecting to remote, and executing, does PHP waits for result and goes to if { } (in my case), or skips "if" and goes to "return"? In my opinion, PHP waits, becouse it's normal function. Just want to be sure, didn't thought on that before. Best regards.
  23. Problem was that key is not exists so it throw error. I just made checking if key exists in array, do .push, if not first array[key] = new Array(); and then push.
  24. Just one more thing. I want append array with new subarray: In PHP it would be like $events[] = array('ddddddd', 'eeeeee'); $events[] = array('fffffffffff', 'gggggggg'); But, in JS if I use .push it says that object has no method push.
×
×
  • Create New...